String str = "Hello"; Classa a = new classa ();
What is STR and A?
STR and A are actually a pointer. They are not a so-called class, but they don't point to the address (of course, the things in memory are different).
Java pass parameters are always transmitted, such as: Void method (Classa a); Parameters a (value transfer) is a reference (pointing to classa). You can change the properties or status of the object points to the object (String except String is always constant),
Look, what is stored in Collection (ArrayList, etc.) If you call method arraylist.add (a), an element A is added to the ARRAYLIST, which is just a pointer to ClassA. So you call When arraylist.add (), a new element must be New, otherwise it will return the same value when you (), as follows:
Collection col = new arraylist ();
Train a = new train (1); // TRAIN has an attribute A INT type.
Col.Add (a);
a.a = 2;
Col.Add (a);
A.a = 3;
Col.Add (a);
Iterator it = col.iterator ();
While (it.hasnext ()) {
TRAIN B = (train) it.next ();
System.out.println ("===" B.A); // Returns the result
}