I just started with lists in Java and I'm confused with all this. So basically we have ArrayList and LinkedList which can be defined like
LinkedList<String> s = new LinkedList<String>();
ArrayList<String> s = new ArrayList<String>();
But then we also have LinkedIntList which can be defined like for example:
class LinkedIntList {
private ListNode first;
private int size;
LinkedIntList () {
first=null;
size=0;
}
LinkedIntList(LinkedIntList l) {
first = l.getFirst();
size=l.size();
}
ListNode getFirst() {return first;}
int size() {return size;}
}
But this is my problem, why define LinkedIntList using a class? What is the difference comparing to LinkedLists where we just define like I stated. I can't understand why a class is being used. If this is a 'new type' of array why using a class instead of declaring it normally?
Sorry if this sounds weird, but I'm a beginner and really need help at this.
Thank you!