1、首先应该注意到作为成员变量的 name 是使用字面量直接赋值的 ( privateString name ="abc"; ) 这种赋值的执行过程是先看字符串常量池中有没有 value 数组为 ['a', 'b', 'c'] 的 String 对象,如果没有的话就创建一个,有的话就拿到他的一个引用。
以下程序执行后,错误的结果是() public class Test { private String name = "abc"; public static void main(String[] args) { Test test = new Test(); Test testB = new Test(); String result = test.equals(testB) + ","; result += test.name.equals(testB.name) + ","; result += test.name == testB.name; System.out.println(result); } }
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2FquestionTerminal%2F02c09e046b17449189eb93cdffa5ea27
全部评论
相关推荐
点赞 评论 收藏
分享
查看8道真题和解析 点赞 评论 收藏
分享
