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
全部评论
相关推荐
查看23道真题和解析 点赞 评论 收藏
分享
夜夜还好:我们学校说为了学生就业,更新了课程,我今天大二,上学期在学jsp,html,这学期上来工程实践,要求用springboot+vue,说什么这些技术要我们提前自己准备,要不你把学费还我吧,我给b站充个会员,人家教的比你多 点赞 评论 收藏
分享