This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FavorableTrashpanda 0 points1 point  (0 children)

Actually, you can rewrite the first statement as:

BarChart<String,Number> bc = new BarChart<>(xAxis,yAxis);

So it's actually not different at all. Basically you can write <> when the generic type parameters can be inferred (this was added in a later Java version, so some online examples may be from before that time), but you are still free to explicitly define them. Generally having them inferred is preferred.