Campbell Ritchie

Marshal
+ Follow
since Oct 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
377
In last 30 days
0
Total given
1140
Likes
Total received
8659
Received in last 30 days
15
Total given
707
Given in last 30 days
2
Forums and Threads
Scavenger Hunt
Rancher Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

Recent posts by Campbell Ritchie

I am afraid I can't understand what is going on. The screenshots are (as screenshots so often are) difficult to understand. Did that code run? It ought to. You simply need to feed SimpleGui3.main(null); to JShell. As I said, the bits you missed out were adding the two Components to the Frame.
Please look at ActionListener and work out why it is a Functional Interface, even though it isn't flagged with that annotation. Hint: you do it by counting methods. Then go to the Java™ Tutorials and find out how I converted the body of the addActionListener() call to a λ expression.
21 hours ago
Beware: tangent!

Why might Piet's method reference be better than Mike's? Apart from being shorter, that is.

Mikalai Zaikin wrote:. . . it's more efficient to use takeWhile instead of filter . . .

The original of that book, and that code, was written for Java8, and takeWhile() and dropWhile() are not to be found in Java8. I think that was a deficiency in Java8, but it was remedied in Java9. Urma Fusco and Mycroft obviously didn't introduce takeWhile() and dropWhile() at that stage. If you don't sort the List, those methods might not be appropriate.
2 days ago
Welcome to the Ranch

Adrian Newy wrote:. . . how many correct options you should check. . . .

It wouild be very unfair not to give that information. If it says there are two right answers, you must click two options, or you will lose the mark.
In the second case, it is likely that b is a variable declared outwith the λ, and yes, a parameter or local variable does have to be effectively final, but maybe that is what the authors intended. We might be more confident with a bit more context please.
Many people believe there should be no such thing as a static variable, using static fields only for constants.
I couldn't get that code to work, Carey. This SO thread says you can't do it with a text area, but only with a text pane or editor pane, quoting this Java™ Tutorials page.
4 days ago

kevin Abel wrote:. . . JShell . . . I don't remember if I installed it or if it comes with Java.

It has come with all versions of Java® since 9.

. . . Do I put your code in a text file and give it a .JSH extension?

I never do that. I simply write (or copy'n'paste) the code directly onto the terminal.

. . . the main method.  I don't know if I have to remove it or it is optional. . . .

Optional. It is possible to call Foo.main(null); on JShell, but that is easier if you declare it as public static void main(String... args). You can then write Foo.main();
5 days ago

Mike Simmons wrote:. . . Aside from the fact that String has no "-" operator defined?  I guess you meant using the Integer example from before . . .

Yes, I did.

Sorry, but I can't work out how to get rid of the <br/> tags.
5 days ago
That would in your case take a Stream<Person> and map that person to a String (the name), and then create a new Stream<String>.
Find yourself a copy of Modern Java in Action by Urma Fusco and Mycroft (Manning, 2018) or one of its predecessors and read that. It is the best explanation of how Streams work that I can remember seeing.
5 days ago
You doubtless already know that there are usually multiple ways to do the same thing. The link you provided seems to say the same in Java22.
In the second code example (please use the code button) you are creating a Collector from its three parts. that makes it easier to run in parallel. The example you showed creates a List (actually, it is very specific about the exact sort of List wanted), and that is a starting point, calling the List's constructor.
The middle part tells you that whenever you encounter an element, it is to be added with the add() method.
When the separate parallel operations finish, the two Lists are put together and one collects all the results from the other with the addAll() method.
The variable stream is a notional variable meaning any sort of Stream, irrespective of how you created it. It is of course, a Stream<T>, and the compiler “knows” how to choose all the other generic type parameters for the rest of the Stream's progress.
5 days ago
But you can't use mapToInt() in the following scenario.By the way, read the documentation for reduce() and find out whywon't work correctly.
5 days ago
Welcome to the Ranch

I think the original WhatsApp group will, by now, be inactive.
Please always tell us the full details; missing out the bit about input being already sorted has caused a bit of confusion.
Remember, in a sorted array or list, all elements with the same value will be adjacent to one another.
1 week ago


vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |