java 代码。= -=
package com.da; //toString()方法, //Object类重写。。。 public class ty { private String name; private int age; private double high; private String sex; public ty(String a, int b, double c, String d) { name = a; age = b; high = c; sex = d; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public double getHigh() { return high; } public void setHigh(double high) { this.high = high; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public String toString() { return "姓名:" + name + "年龄;" + age + "身高:" + high + "性别:" + sex; } public boolean equals(Object o) { if (((ty) o).name == this.name && ((ty) o).age == this.age) { return true; } return false; } public static void main(String[] args) { ty d = new ty("啊", 3, 1.5, "男"); ty d1 = new ty("啊", 3, 1.1, "女"); System.out.println(d.toString()); System.out.println(d.equals(d1)); } }