• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New APIs

 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
A.J. Côté wrote:. . . Don't take for granted everybody has time to look at all the nifty features when a new java version is released. . . .
It is one of the big features of Java8 which makes Streams possible. It is surprising that you missed it.


The only thing I know about java 1.8 is that it has a new Calendar API and that interfaces support static methods, thanks to javaranch! ;-)

I won't be able to use those features for a while anyway for the reasons I already stated on this thread. I am typically 5 or more years behind regarding java versions and I couldn't care less but I catch up really fast when needed.
 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Original thread: http://www.coderanch.com/t/656799/java/java/Static-methods-interfaces

The Java Time API is truly wonderful. However, to me it's the Streams API that makes Java 1.8 stand out, like generics for Java 1.5 and try-with-resources for Java 1.7. It's definitely worth checking out.
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:The Java Time API is truly wonderful. However, to me it's the Streams API that makes Java 1.8 stand out, like generics for Java 1.5 and try-with-resources for Java 1.7. It's definitely worth checking out.


Thanks, I have always liked streams, it beats buffering the whole thing into memory. I'll take a peak into it when I get a chance. Never heard of it (in java 1.8).

try-with-resources for Java 1.7: I haven't got the slightest idea what you are talking about ;-)

Cheers,
 
Campbell Ritchie
Sheriff
Posts: 51366
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Streams are a lot better than try‑with‑resources. Maybe the new memory model and new threading capabilities was a bigger change in Java5 even than generics. But the capabilities of a Stream mean you can forget all about the new threading models and simply parallelise your streams. And if that isn't a dreadful exaggeration, I don't know what is.
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Streams are a lot better than try‑with‑resources. Maybe the new memory model and new threading capabilities was a bigger change in Java5 even than generics. But the capabilities of a Stream mean you can forget all about the new threading models and simply parallelise your streams. And if that isn't a dreadful exaggeration, I don't know what is.


Ha, these are different than i/O streams aren't they?
 
Campbell Ritchie
Sheriff
Posts: 51366
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very different. Yes.
 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. They allow you to write code like this:
 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The nice thing about them is that they evaluate lazily, so Country.capital() is only called on European countries, and not all of them.
 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The old way is:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic