1 public class Y {
2 public static void main(String[] args) {
3 // TODO Auto-generated method stub
4 new Y().fun();
5
6 }
7
8 private void fun() {
9 System.out.println("L-Y-H");
10 }
11
12 }
1 public class L {
2 String name;int age;
3 public L(String name,int age) {
4 this.name = name;
5 this.age = age;
6 }
7 public boolean compare(L per) {
8 if(this == per) {
9 return true;
10 }
11 if(this.name.equals(per.name) && this.age == per.age) {
12 return true;
13 }else {
14 return false;
15 }
16 }
17 public String getName() {
18 return this.name;
19 }
20 public int getAge() {
21 return this.age;
22 }
23 public static void main(String[] args) {
24 // TODO Auto-generated method stub
25 L per1 = new L("cousins",26);
26 L per2 = new L("cousins",26);
27 if(per1.compare(per2)){
28 System.out.println("这俩人一个样~");
29 }
30 }
31 }