I know you can create your own Linked List class or import one with java.util. Like so :
import java.util.*;
LinkedList<String> ll=new LinkedList<String>();
and then do some stuff to the list with the already existing methods, like add, get, set... But you can also create your own Linked List liked that :
class LinkedList {
Node head; // head of list
class Node {
int data;
Node next;
Node(int d) { data = d; }
}
}
But if you're doing it like that you need to create all of the methods. My question is pretty simple, should I use method 1 or 2 ? And if both are fine when would it be better to use one over another.