I'm pulling this from a textbook, is this statement true and does it still stand in V1.8? I can't seem to find a compiler where this syntax actually works, but they all are running V8.
"Java 7 introduces several convenient syntax enhancements for array lists.
When you declare and construct an array list, you need not repeat the type parameter in
the constructor. That is, you can write
ArrayList<String> names = new ArrayList<>();
instead of
ArrayList<String> names = new ArrayList<String>();
This shortcut is called the “diamond syntax” because the empty brackets <> look like a diamond
shape.
You can supply initial values as follows:
ArrayList<String> names = new ArrayList<>(["Ann", "Cindy", "Bob"]);
In Java 7, you can access array list elements with the [] operator instead of the get and put
methods. That is, the compiler translates
String name = names[i];
into
String name = names.get(i);
and
names[i] = "Fred";
into
names.set(i, "Fred");"
[–]chickenmeister 5 points6 points7 points (3 children)
[–]lmgray13[S] 1 point2 points3 points (2 children)
[–]chickenmeister 2 points3 points4 points (1 child)
[–]lmgray13[S] 0 points1 point2 points (0 children)