Java object-oriented memory map

1. java virtual machine's memory division

 2. Apple phone category

cn.itcast.day06.demo02 Package Penalty for; 

/ * 
define a class, used to simulate the "mobile phone" thing. 
Properties: brand, price, color 
behavior: phone calls, send text messages 

corresponds to class them: 
member variables (attributes): 
    String Brand; // brand 
    double price; // price 
    String color; // color 
member method (behavior): 
    public void call (String who) {} // call 
    public void sendMessage () {} // bulk SMS 
 * / 
public class Phone { 

    // member variables 
    String brand; // brand 
    double price; // price 
    String color; // color 

    // member methods 
    public void call (String WHO) { 
        System.out.println ( "a" + who + "call"); 
    } 

    public void the sendMessage () {
        System.out.println ( "bulk SMS"); 
    } 
}

2.1 a memory map objects 

 2.2 two objects using a method

 2.3 two objects point to the same reference

2.4 Parameter object type as a method of using 

 2.5 As a method of using the object type of the return value

Guess you like

Origin www.cnblogs.com/yzg-14/p/12190021.html