I have instantiated two ArrayList() objects. The first one goes into an ArrayList reference and the second one goes into just List reference. I understand that List is an interface and it cannot be instantiated.. so the following won't work and produces the compiler's wrath.
But is there a preference to using one over the other in any situation or is one more efficient than the other? I might be getting ahead of myself asking this question, but what exactly is happening when you instantiate an ArrayList object and store it in a List reference?
In addition to this, if I could beg one more question here:
I tried to do some research into Object[]. From the Oracle docs "Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class."
My book only lightly graces over it in passing saying that Object[] is more broad than
String[] so no casting is required. String[] can go into Object[], but I tried int literal and Integer wrapper class and these produce the scary red lines underneath them. How could I appease the compiler? Again, why would a programmer want to store a String array in an Object reference?