3

so I have this java code that input stuff and puts it into an array list:

public void adding() { 
    boolean loop = true;
    ArrayList<Game> thegame = new ArrayList<Game>();
    while(loop) {
        Scanner agame = new Scanner(System.in);
        System.out.print("name: \n");
        String Cgame = agame.nextLine();
        Scanner qty = new Scanner(System.in);
        System.out.print("the qty: \n");
        int CQty = qty.nextInt();


        Console wertgame = new Console(Cgame,Cqty);
        thegame.add(new Game(Cgame,Cqty));

        System.out.println("continue?");
        Scanner autre = new Scanner(System.in);
        int continu = other.nextInt();
        if(continu==1) {

        }
        else if(continu==2) {
            Main.menu();
        }
    }

    return thegame; 
}

However,im wondering how to use the list in other methods,I tried some things like

public void information(List<thegame>) {  
    System.out.print(thegame);  
})

I want to be able to use the list in other methods and be able to display it and also modify it.Im quite a beginner in Java.

1 Answer 1

6

You havent declared thegame as parameter. Change

 public void information(List<thegame>) {  
        System.out.print(thegame);

    }}

to

public void information(List<Game> thegame) {  
        System.out.print(thegame);

    }}
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.