为了账号安全,请及时绑定邮箱和手机立即绑定

索引怎么写

索引怎么写

丶厌倦 2016-06-17 16:43:38
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));

这样?

查看完整回答
反对 回复 2016-06-17
  • 1 回答
  • 0 关注
  • 1535 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号