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()方法来比较所有引用的结果
求大神解答
yanrun
相关分类