1

"Syntax error on token 'al1, VariableDeclaratorID expected after this token" on the x.add(al1); line. Any idea why this is occuring? Ignore line 3

import java.util.ArrayList;
public class GameState {//creates a list of the three coins to work with
private ArrayUnsortedList<Coin> coins = new ArrayUnsortedList<Coin>(3);
    private ArrayList<ArrayList<Integer>> x = new ArrayList<ArrayList<Integer>>(3);
    private ArrayList<Integer> al1 = new ArrayList<Integer>();
    private ArrayList<Integer> al2 = new ArrayList<Integer>();
    private ArrayList<Integer> al3 = new ArrayList<Integer>();
    x.add(al1);
0

1 Answer 1

2

Yes. It's not in an initializing block (and I think that's what you wanted). Something like

{
    x.add(al1);
}

which will be copied into any constructor (so you could put it in the constructor).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.