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.Mikalai Zaikin wrote:. . . it's more efficient to use takeWhile instead of filter . . .
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.Adrian Newy wrote:. . . how many correct options you should check. . . .
It has come with all versions of Java® since 9.kevin Abel wrote:. . . JShell . . . I don't remember if I installed it or if it comes with Java.
I never do that. I simply write (or copy'n'paste) the code directly onto the terminal.. . . Do I put your code in a text file and give it a .JSH extension?
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();. . . the main method. I don't know if I have to remove it or it is optional. . . .
Yes, I did.Mike Simmons wrote:. . . Aside from the fact that String has no "-" operator defined? I guess you meant using the Integer example from before . . .