zoukankan      html  css  js  c++  java
  • Practical Java笔记一:区别引用类型和原始类型

    public class RefereceAndPrimit {


    public static void main(String[] args) {
    int a = 1;
    int b = 2;
    Point x = new Point(0,0);
    Point y = new Point(1,1);

    System.out.println("a is "+a);
    System.out.println("b is "+b);
    System.out.println("x is "+x);
    System.out.println("y is "+y);
    System.out.println("a is "+a);
    System.out.println("------------");

    a = b;
    a++;
    x = y; //修改的是object reference而不是object本身,x和y都是指向同一对象,所以对x改变同时也对y改变
    x.setLocation(5, 5);

    System.out.println("a is "+a);
    System.out.println("b is "+b);
    System.out.println("x is "+x);
    System.out.println("y is "+y);

    }

    }
  • 相关阅读:
    poj2679
    poj2709
    poj1521
    poj2054
    静脉曲张病案
    眩晕耳鸣病案
    声嘶治验
    甘露消毒丹治疗高热不退一例
    黄芩汤加减治疗腹痛一例
    自残症治愈案
  • 原文地址:https://www.cnblogs.com/andgoo/p/2395202.html
Copyright © 2011-2022 走看看