Getting to know java basis of (a)

java brief overview

Although java is based on C ++, but in contrast, it is a more pure java object-oriented language. Suppose we only java language object-oriented programming, that is, before you begin designing with java, you must convert to the idea of ​​object-oriented world of them, this is the basic entry, you can have such a programming language the ability of this relatively simple language, other than the need of OOP (object oriented) language easier to use, we will see the fundamental part of the java program and basic components java experience and appreciate the java.

Java embodiment of the operating element

Each programming language has a memory element in the way of their operations, sometimes, the programmer must be noted that the data to be processed is what type. You are direct operating elements, or representation (such as C and C ++ pointers) with the introduction of a particular syntax. All of this in java, have been simplified. Everything is an object, and therefore can be fixed grammar, everything as an object. Identifier operation but is actually a reference object (reference). This situation may be thought of as a remote control (reference) to operate the television (the object). As long as you're holding this remote control, you can remain connected to the TV. When someone wants to change the channel or decrease the volume, the actual control is a remote control (reference), then by remote control to regulate television (the object). For example: String str; here you've created only a reference, not an object.

 

Creating objects

Once you have created a reference, I hope he can be associated with a new object. This object is generally achieved by the new operator. new keyword means "give me a new object."

// str is a reference, the right is held by the object str 
String str = new new String ( "yongjar" );
// equivalent
String str = "yongjar";

Object storage to the place

1) Register: This is the fastest storage area, because it is located where --- is different from the internal processor of the other storage area. However, there is a limited amount of memory, the register allocation on demand. You can not directly control, can not feel the presence of the register in the program.

2) Stack: typically located in RAM, but can be directly supported from where the processor stack pointer.

3) reactor: a common memory pool (also located in RAM area) for storing all the java objects. The benefits of the stack is different: the compiler does not need to know the data stored on the heap survive a long time. Allocate storage on the heap of great flexibility.

4) Constant storage: constants are stored usually stored in the program code,

5) Non-RAM memory: such as a hard disk and the like.

 

Guess you like

Origin www.cnblogs.com/jamal/p/10956061.html