集册 Java实例教程 静态字段与实例字段

静态字段与实例字段

欢马劈雪     最近更新时间:2020-01-02 10:19:05

440
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
静态字段与实例字段

public class IdentifyMyParts {

    public static int x = 7;/*from 时代Java公众号 - N o w J a  v a . c o m*/

    public int y = 3;


    static public void main(String[] args) {

        IdentifyMyParts a = new IdentifyMyParts();

        IdentifyMyParts b = new IdentifyMyParts();

        a.y = 5;

        b.y = 6;

        a.x = 1;

        b.x = 2;

        System.out.println("a.y = " + a.y);

        System.out.println("b.y = " + b.y);

        System.out.println("IdentifyMyParts.x = " + a.x);

        System.out.println("b.x = " + b.x);/** from 时代Java公众号**/

    }

}


展开阅读全文