13

 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 
13 ublic class L {
14     String name;int age;
15     public L(String name,int age) {
16         this.name = name;
17         this.age = age;
18     }
19     public boolean compare(L per) {
20         if(this == per) {
21             return true;
22         }
23         if(this.name.equals(per.name) && this.age == per.age) {
24             return true;
25         }else {
26             return false;
27         }
28     }
29     public String getName() {
30         return this.name;
31     }
32     public int getAge() {
33         return this.age;
34     }
35     public static void main(String[] args) {
36         // TODO Auto-generated method stub
37         L per1 = new L("cousins",26);
38         L per2 = new L("cousins",26);
39         if(per1.compare(per2)){
40             System.out.println("这俩人一个样~");
41         }
42     }
43 }

 

posted @ 2017-12-18 14:27  mxl-1  阅读(144)  评论(0编辑  收藏  举报