黑马程序员技术交流社区

标题: 经典赋值判断 [打印本页]

作者: 18463730277    时间: 2015-5-12 23:59
标题: 经典赋值判断
public class Student {
        public static void main(String[] args) {
                int x = 10;
                int y = 10;
                System.out.println(x == y);
                Student s1 = new Student();
                Student s2 = new Student();
                Student s3 = s1;
                System.out.println(s1 == s2);
                System.out.println(s1 == s3);
}}


作者: 喻忠航    时间: 2015-5-13 00:34
true  false true    第一个是判断int值,都是10,所以相等ture,第二个是new出来的地址值肯定不一样false,第三个是赋值,把第一个的地址值赋给了S3,所以是true     我是菜鸟  不知道对不对




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2