Download Java and java Official Website
For the value assignment operation "=", the actual value is stored for the basic data type,
"Assigning an object to another object" means copying a reference from one place to another.
The object is"Alias symptom".
Example:
//: Main. javaclass FloatType {float f;}/*** alias mechanism example */public class Main {public static void main (String [] args) {FloatType f1 = new FloatType (); floatType f2 = new FloatType (); f1.f = 4; f2.f = 8; System. out. println ("f1.f =" + f1.f + ", f2.f =" + f2.f); f1.f = 16; f2.f = 32; System. out. println ("f1.f =" + f1.f + ", f2.f =" + f2.f); f1 = f2; // value assignment operation f2.f = 64; // alias phenomenon, the value of f1.f is also changed to System. out. pr Intln ("f1.f =" + f1.f + ", f2.f =" + f2.f) ;}/ *** Output: * f1.f = 4.0, f2.f = 8.0 * f1.f = 16.0, f2.f = 32.0 * f1.f = 64.0, f2.f = 64.0 *///:~
In a method call, an object is passed as a parameter to a method. In fact, passing a reference also produces an alias.
//: Main. javaclass FloatType {float f;}/*** method call alias Mechanism */public class Main {static void change (FloatType of) {. f = 32;} public static void main (String [] args) {FloatType of = new FloatType ();. f = 4; System. out. println (". f = "+. f); change (of); // the reference of the method call is passed to System. out. println (". f = "+. f) ;}}/*** Output: *. f = 4.0 *. f = 32.0 *///:~
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.