public class Y { public static void main(String[] args) { // TODO Auto-generated method stub new Y().fun(); } private void fun() { System.out.println("L-Y-H"); } }
public class L { String name;int age; public L(String name,int age) { this.name = name; this.age = age; } public boolean compare(L per) { if(this == per) { return true; } if(this.name.equals(per.name) && this.age == per.age) { return true; }else { return false; } } public String getName() { return this.name; } public int getAge() { return this.age; } public static void main(String[] args) { // TODO Auto-generated method stub L per1 = new L("cousins",26); L per2 = new L("cousins",26); if(per1.compare(per2)){ System.out.println("这俩人一个样~"); } } }