原文 http://www.wellho.net/mouth/985_Equality-in-Ruby-eql-and-equal-.html Equality in Ruby - == eql? and equal? The == comparison checks whether two values are equal eql? checks if two values are equal and of the same type equal? checks if two things a…
java String 是不可改变的类型. String a = "hello2"; String d = "hello"; final String b = "hello"; String c = b + "2";// final相当于常量,编译阶段直接加入常量池 String cc = “hello”+“2”: 类似于 final修饰的,在编译期间,会自动优化处理为:hello2 并加入常量池,所以和a比较相等,和e比较不…
==比较的是对象的地址,也就是是否是同一个对象: equal比较的是对象的值. Integer r1 = new Integer(900);//定义r1整型对象Integer r2 = new Integer(900);//定义r2整型对象System.out.println(r1==r2);//返回falseSystem.out.println(r1.equal(r2));//返回true =============equal是用来判断一个字符串的,比如:String s = test;if…