I am just trying to be a little more familiar with arrayList and made a test program. I just want to add data into an arrayList of another class. It says that "The method add(arrayList) in the type Test is not applicable for the arguments (String)"
package arrayList;
import java.util.ArrayList;
import java.util.List;
public class arrayList
{
public static void main(String[] args) throws Exception
{
ArrayList<String> cityList = new ArrayList<String>();
// Add some cities in the list
Test add = new Test();
add.add("Dallas");
System.out.print(cityList);
}
}
Here is the class that adds data into the arrayList package arrayList;
import java.util.ArrayList;
import java.util.List;
public class Test
{
public final ArrayList<arrayList> floors = new ArrayList<>();
public void add(arrayList cityName)
{
floors.add(cityName);
}
}
floorsarray or thecityListarray?