-4

I've been having a thousand issues with my code and am not sure what is wrong with it. This code runs perfectly in the eclipse IDE, but when I take it out to try in Ready to program java it prompts me with a compilation error from the following code:

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

and

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

Give the errors:

Invalid assignment operator

!= expected instead of this token

misplaced construct(s)

Invalid name

Invalid assignment operator

!= expected instead of this token

misplaced construct(s)

Invalid name

My environment is Windows 7 running JRE 6 (I must use jre6, I cannot update it)

What is the issue in my code? What should I change so it works?

Mr. Llama
  • 20,202
  • 2
  • 62
  • 115
user2966992
  • 13
  • 1
  • 4

2 Answers2

2

With JDK 6, you haven't the nice syntaxic sugar ArrayList<>();.
JDK 7 has it.

You have to explicitly declare as following, if you use JDK 6:

ArrayList<Integer> row = new ArrayList<Integer>();
Mik378
  • 21,881
  • 15
  • 82
  • 180
0

Try including the same type indicator in your new ArrayLists like so:

ArrayList<ArrayList<Integer>> tempLayout = new ArrayList<ArrayList<Integer>>(); 
ArrayList<Integer> row = new ArrayList<Integer>();
bob0the0mighty
  • 782
  • 11
  • 28
  • I understand what you are doing, I tested it and I still get very similar errors: `Invalid assignment operator` etc.... They are on the `< = < (` areas.... – user2966992 Jun 17 '14 at 20:58