0

Here is a constructor for creating a BarChart object:

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

Here is a constructor for creating an ArrayList:

ArrayList<Integer> arrayList = new ArrayList<>();

Why do we add something in the diamond brackets <> and the parentheses () for the BarChart constructor but leave them blank for the ArrayList?

fdama
  • 175
  • 3
  • 6
  • 15
  • "Why do we add something in the diamond brackets ... for the `BarChart`" you don't need to. It's hard to say why it was so written without more context: perhaps the `BarChart` constructor invocation was written when using a version of Java which predated the diamond operator (i.e. Java 5 or Java 6). – Andy Turner Mar 04 '22 at 14:14

0 Answers0