Simple screenshot that explains the non-static invocation.

时间:2014-03-09 03:27:57   收藏:0   阅读:379

Here is the code:

bubuko.com,布布扣
 1 /*
 2 Instance invocation in the memory:
 3 
 4 */
 5 package kju.obj;
 6 
 7 import static kju.print.Printer.*;
 8 public class NonStaticInvoke {
 9     public static void main(String[] args) {
10         Person p = new Person("lily");
11         p.setName("lucy");
12     }
13 }
14 
15 class Person {
16     public static final String country = "cn";
17     private String name;
18     public Person(String name) {
19         this.name = name;
20     }
21 
22     public static void showCountry() {
23         println("country = " + country);
24     }
25 
26     public void setName(String name) {
27         this.name = name;
28     }
29 }
bubuko.com,布布扣

The figure below corresponds to the above code:

bubuko.com,布布扣

Simple screenshot that explains the non-static invocation.,布布扣,bubuko.com

原文:http://www.cnblogs.com/listened/p/3588628.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!