猿问

索引怎么写

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()方法来比较所有引用的结果

求大神解答

丶厌倦
浏览 1460回答 1
1回答

yanrun

Dog anotherDog = spot; System.out.println(anotherDog == spot); System.out.println(anotherDog.equals(spot));这样?
随时随地看视频慕课网APP

相关分类

Java
我要回答