I just learned about ArrayLists from my book and how to implement them and such. Please tell me whats different (besides the ammount and names) of these two pieces of code:
ArrayList<String> coordsComp = new ArrayList<String>(); String space11 = "(1,1)"; String space12 = "(1,2)"; String space13 = "(1,3)"; String space21 = "(2,1)"; String space22 = "(2,2)"; String space23 = "(2,3)"; String space31 = "(3,1)"; String space32 = "(3,2)"; String space33 = "(3,3)"; coordsComp.add(space11); coordsComp.add(space12); coordsComp.add(space13); coordsComp.add(space21); coordsComp.add(space22); coordsComp.add(space23); coordsComp.add(space31); coordsComp.add(space32); coordsComp.add(space33);
and
The problem i am having is that the top one won't compile but the bottom one will and i can't see the difference is. Please help! If you need to know the error i get says:
compMove.java:17: <identifier> expected
coordsComp.add(space11);
^
compMove.java:17: <identifier> expected
coordsComp.add(space11);
^
compMove.java:18: <identifier> expected
coordsComp.add(space12);
^
compMove.java:18: <identifier> expected
coordsComp.add(space12);
^
compMove.java:19: <identifier> expected
coordsComp.add(space13);
^
compMove.java:19: <identifier> expected
coordsComp.add(space13);
^
compMove.java:20: <identifier> expected
coordsComp.add(space21);
^
compMove.java:20: <identifier> expected
coordsComp.add(space21);
^
compMove.java:21: <identifier> expected
coordsComp.add(space22);
^
compMove.java:21: <identifier> expected
coordsComp.add(space22);
^
compMove.java:22: <identifier> expected
coordsComp.add(space23);
^
compMove.java:22: <identifier> expected
coordsComp.add(space23);
^
compMove.java:23: <identifier> expected
coordsComp.add(space31);
^
compMove.java:23: <identifier> expected
coordsComp.add(space31);
^
compMove.java:24: <identifier> expected
coordsComp.add(space32);
^
compMove.java:24: <identifier> expected
coordsComp.add(space32);
^
compMove.java:25: <identifier> expected
coordsComp.add(space33);
^
compMove.java:25: <identifier> expected
coordsComp.add(space33);
^
18 errors
Press any key to continue . . .
The carrot points to right before and after space(#) not anywhere else