I am trying to add items of type data to an arraylist, which would display the name and age of 3 individuals in the form of ("Name", Age), I have the following code
import java.util.ArrayList;
public class Arraylist{
public static void main(String args[]){
Data x = new Data("mark",41);
x.Print();
ArrayList<Data> arrl = new ArrayList<Data>();
arrl.add("phil",21);
arrl.add("sarah",43);
arrl.add("william",37);
for(int i=0;i<arrl.size();++i)
{
arrl.get(i).Print();
}
I get an error on the words "add", saying that the method is not applicable for the argument. Any help is much appreciated.
ArrayListthere is anaddmethod that takes a String and then an integer number as its arguments?