Java is based on C + +, but Java is a more purely object-oriented programming language, unlike C + +, Java only supports object-oriented programming, so Java programming style is also pure OOP style, that is, everything is a class, everything is done in the class object.
In Java, the use of references to manipulate objects, in the fourth edition of Java programming thought, the term used is "reference (Reference)", previously read the third version of Java programming thought, in the third edition, the use of the term "handle (handle)", in fact, I think the third edition of the term " Handle "more vivid and vivid, like you use a door handle to open the door to close the door, no tube door is what gate, in short you use the door handle can control operation this door." Of course, using the term "reference" is easier to understand for people with C + + origins, because in C + +, the underlying general uses pointers to implement references, which indirectly manipulate objects through pointers. More in tune, in C + +, the object that is dynamically allocated with new is anonymous, and there is no way to manipulate the object, except for the pointer returned by the new expression at the beginning, in Java, where the object is new and stored in dynamic memory, to use the object, It's going to be manipulated by the object's handle (reference), which virtually links Java to C + +, because both are essentially pointers-like things.
In Java, a reference can exist separately, as in C + +, the pointer is also a standalone existence. We can associate a reference to an object, or we can point the pointer to an object, so the reference (pointer) is independent of the object. As with pointers, it is not possible to use a reference without an associated object. In Java, references to non-associative objects can lead to compilation errors, which in C + + typically results in out-of-bounds memory, which in turn receives the segmentfault signal from the operating system, which is the program Coredump by default if the signal is not captured for processing. As shown in the following:
C++:
Java:
The features of a Java language are also implicitly described here: string strings can be initialized with quoted literals (the word value is the term I took from C + +), as shown in the following example:
String str = "Hello";
Once a reference has been created, in addition to being initialized directly with the above attribute, the reference must normally be managed to an object, and the creation of the object in Java can only be done through new. For the above example, you can write:
New String ("Hello");
Java Programming thought 4th the 2nd Chapter everything is the object