Junilu Lacar wrote:Just as in the other thread you started related to the same class, this is very procedural-style code, not object-oriented at all. Just keep that in mind as you study this code and how the algorithm is implemented. This is more like how you'd do it in C, not Java.
We have already seen that the other code posted was poor quality.
Md Zuanyeed Kamal wrote:. . . The way author solved problem made me very confused. . . .
Md Zuanyeed Kamal wrote:I will come up with my own solution rather than following author solutions.
Campbell Ritchie wrote:Can you get that Comparator to work, Piet? Surely your λ will have a boolean return type and a Comparator wants an int? Will that code actually compile?
Piet Souris wrote:I will give it a shot and see if it is indeed a triviality!
I thought the time to start thinking about Streams as part of Beginning Java® was 17th March 2014 (Java8 came out on 18th March 2014)
Jesse Silverman wrote:. . . time to start thinking of streams as part of Beginning Java. . . ..
That goes without saying. I wouldn't show a beginner this sort of thing at all, which I think belongs in a non‑beginner's course:-Should we plague beginners by telling them that you can get an int 0, 1, 2, 3...8, 9 like this:-or like this?Yes, I know I would just as soon use an array initialiser, but I can easily scale the other versions to much larger arrays.
Junilu Lacar wrote:. . . Some simple examples . . .
Agree. We still see people who don't know how to use a Scanner to read a text file, nor to use try with resources to close said Scanner.
Jesse Silverman wrote:. . . stop teaching modern Java by teaching Java 7 with all of the Streams stuff left as an advanced topic.
I had to learn Collections without generics because I learnt on Java1.4.
. . . teach Collections barely acknowledging generics at all . . . teaching Generics only at the end and saying "It's better to do things like this."
Explicit Threads, JOptionPane for keyboard input, File, AWT, remote Java®, Vector, ints in enumerated types, new Integer(123), the finalize() method, Date and Calendar?
. . . almost nothing from Java 1.0 is de-supported . . .
Because they can pick up old books very cheaply, and don't actually know how out of date they are. Until the are asked at interview to read a text file and they write this sort of code:-...or even,
. . . people who have started seriously learning Java only recently, but are using older materials . . .