This is my code for the class, ListOfLists. The constructor should make an array of type NameList.
public class ListOfLists {
private int capacity;
private NameList[] listOfLists;
private int size = 0;
public ListOfLists(int capacity) {
listOfLists = new NameList[capacity];
}
My NameList class looks something like this..
public class NameList{
public NameList(String initial){
i = initial;
}
public void add(String data){
...
}
If I make a new object in the Main of ListOfLists called k..
ListOfLists k = new ListOfLists(5);
How come I cannot do..
k.add("Whatever") ?
I get the error.. The type of the expression must be an array type but it resolved to ListOfLists