cxxr / better-java

Resources for writing modern Java
Other
5.79k stars 730 forks source link

Correct Java 8 streaming example #6

Closed calebperkins closed 10 years ago

calebperkins commented 10 years ago

Use the diamond syntax in the Guava section.

Corrected the Java streaming example. The stream needs to be transformed into a List before it can be assigned to List. Also, use standard Java array list initialization instead of the Guava factory method.

cxxr commented 10 years ago

The change in the Guava section is certainly true for Java 8, but not true for any other Java version. Maybe we can include the new syntax in a comment?

The other change to the stream interface is obviously correct.

calebperkins commented 10 years ago

The diamond syntax was introduced in Java 7, so it's been around for a couple years.

I think it's important to use that in Guava example because it more accurately shows the difference in verbosity between the library and standard Java.

cxxr commented 10 years ago

My mistake. This looks great then.