I want to pass the ArrayList <String> variable, but I get an error.

Asked 2 years ago, Updated 2 years ago, 23 views

For information on how to pass ArrayList variables in JAVA, see
I'm looking it up on the Internet, but
In the line receive(list); below, suppose the elicpse is in red and the argument type is different.

How can I give you a list?

private ArrayList<String>list=new ArrayList<String>();;

public test()
{
   list.add("first";
   list.add("Second");

   receive(list); //eclips show here as red and different types
}

public receive (ArrayList<String>list_test)
{
   for(i=0;i<list_test.size();i++){
      System.out.println(list_test.get(i));
   }
}

java

2022-09-29 22:24

1 Answers

Similarly, specifically

publicvoidtest()

and so on

publicvoidreceive(ArrayList<String>list_test)

Then it will be resolved.


2022-09-29 22:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.