I still can't understand when and why should I use the "Obj obj = new Obj" and I don't get why it's so difficult for me. In this assignment I need to create a method as it follows:
"insertSorted: This method assumes the input LinkedList is already sorted in non-descending order (i.e.,such that each element is greater than or equal to the one that is before it, and inserts the input int value into the correct location of the list. Note that the method does not return anything, but rather modifies the input LinkedList as a side effect. If the input LinkedList is null, this method should simply terminate. This is the code you're starting with:
public static void insertSorted(LinkedList<Integer> list, int value) {
/* IMPLEMENT THIS METHOD! */
}
Let alone all the complications about iterating the LinkedList list, I don't even know how to start.
Should I create a new LinkedList<Integer> newList = new LinkedList<Integer>(); so I can iterate through it right? Why though? If the list is given in the method signature should I assume that the Object is already created when the input is given in the method signature?
I am really confused. It seems that I can't quite catch the whole Object programming thing.