本帖最后由 冷叙辰 于 2013-3-14 18:51 编辑
- public class Student {
- private String name;
- private int age;
- public Student(String name,int age)
- {
- this.name=name;
- this.age=age;
- }
- public static void main(String[] args)
- {
- Student st1 = new Student("zhang",20);
- Student st2 = new Student("zhang",20);
- if(st1.equals(st2))
- System.out.print("相等");
- else
- System.out.print("不相等");
- }
- }
复制代码 为什么输出不相等? |
|