您的位置:首页 > 大数据 > 人工智能

Simple screenshot that explains the non-static invocation.

2014-03-08 21:21 501 查看
Here is the code:

/*
Instance invocation in the memory:

*/
package kju.obj;

import static kju.print.Printer.*;
public class NonStaticInvoke {
public static void main(String[] args) {
Person p = new Person("lily");
p.setName("lucy");
}
}

class Person {
public static final String country = "cn";
private String name;
public Person(String name) {
this.name = name;
}

public static void showCountry() {
println("country = " + country);
}

public void setName(String name) {
this.name = name;
}
}


The figure below corresponds to the above code:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: