首页 > 其他 > 详细

Simple screenshot that explains the non-static invocation.

时间:2014-03-09 03:27:57      阅读:378      评论:0      收藏:0      [点我收藏+]

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

Simple screenshot that explains the non-static invocation.

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!