public class Sample22 {int x = 5;public static void main(String[] args) {Sample22 myObj1 = new Sample22(); // obj1Sample22 myObj2 = new Sample22(); // obj2// System.out.println(myObj1.x);// System.out.println(myObj2.x);// 打印obj1和2的内存地址值,会发现是不一样的, 虽然他们都是类Sample22的实例对象, 但是截然不同的。 比如 小明和小红都是人, 但是是不同的个体。System.out.println("myObj1: " + Integer.toHexString(System.identityHashCode(myObj1)));System.out.println("myObj2: " + Integer.toHexString(System.identityHashCode(myObj2)));System.out.println(myObj1 == myObj2);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。