33 Java serialized object creation and usage, memory analysis

First, create a class of students

Each student has a Student ID information, but each student's student number is different, so visit the Student ID must be created object, the object information to access student number, student number information can not be directly through the "class" to access, so this member variable is also called "instance variables"

note:

(1) Object and is known as an example, instance variables of an object is also known as variable (an object variable level)

(2) does not create an object, the Number of the memory space does not exist, only creates an object, this number will be created variable memory

(3) a plurality of objects can be instantiated by a class

Syntax (4) object instantiation

 

new class name ();

 

 

(5) new is a java language operators

(6) the role of the new operator: create objects, open up two new memory space in the JVM heap memory

(7) Method region memory: when the class is loaded, class byte code snippet is loaded in the memory space

(8) stack memory (local variables): when the method code segment is executed, which will allocate memory space in the memory stack, the stack is incremented

(9) heap memory: new object is stored in the heap memory;

(10) D32_student data type is a reference, s is a variable name, new D32_student () the object is a student, s is a local variable (stored in the stack memory)

(11) What is an object? new operator opened memory space in the heap is called the object

(12) What is a reference? Reference is a variable, but this variable holds the memory address of another java object

(13) java language, can not directly operate the heap memory, java no pointers, not want C language

(14) java language, only through the "reference" to access the interior of the heap memory object instance variables

(15) access instance variables syntax:

 

Reading data: a reference variable name. 

Modify data: a reference variable name = value

 
      

For example:

 

public  class D33_student2_test { 

  public  static  void main (String [] args) { 

    D32_student S = new new D32_student (); 

    System.out.println ( "jfahsf" ); 

    S.No = 154 ; 

    s.address = "jafalj" ; 

    the System. Out.println (S.No); 

    D32_student S2 = new new D32_student (); 

    System.out.println (s2.no); 

    // following procedures being given, because no instance variable is not directly a "class name" of access 

    / / because no instance variables, object-level variables, variables are stored in the internal java objects must have an object, because the object can access no instance variable 

    // can not be directly through the "class name" to access 

    //System.out.println (D32_student () NO.); 

  } 

} 

Class D32_student { 

  // public static main (Sting [] args) { 

  int NO; // Science Number 

  String name; // name 

  int Age; // Age 

  boolean sex; // gender 

  String address; // address 

  // is the object described operation information, the method of the present example is not described, only the description of the attribute information 

  // } 

}

 

Second, the source code:

D33_student2_test.java

address:

https://github.com/ruigege66/Java/blob/master/D33_student2_test.java

2.CSDN: https: //blog.csdn.net/weixin_44630050 (Xi Jun Jun Moods do not know - Rui)

3. Park blog: https: //www.cnblogs.com/ruigege0000/

4. Welcomes the focus on micro-channel public number: Fourier transform public personal number, only for learning exchanges, backstage reply "gifts" to get big data learning materials

 

 

Guess you like

Origin www.cnblogs.com/ruigege0000/p/11570169.html