package com.imocc;import java.util.*;public class Dog { String name; String says; public static void main(String[] args) { Dog spot = new Dog(); spot.name = "Ruff!"; Dog scruffy = new Dog(); scruffy.says = "Wurf!"; System.out.println("spot的叫声为:" + spot.name); System.out.println("scruffy的叫声为:" + scruffy.says); } 在这个基础上创建一个新的Dog索引,并对其赋值为spot对象,然后测试用==和equals()方法来比较所有引用的结果求大神解答
1 回答
yanrun
TA贡献317条经验 获得超240个赞
Dog anotherDog = spot; System.out.println(anotherDog == spot); System.out.println(anotherDog.equals(spot));
这样?
添加回答
举报
0/150
提交
取消