• 同一个人


    package nn;
    public class RL{
        private String name;
        private int age;
        public RL(String name,int age){
            this.name =name;
            this.age =age;
        }
        public boolean compare(RL r) {
            if(this.name.equals(r.name)&&this.age==r.age) {
                return true;
                }else {
                    return false;
                    }
        }
        public String getName() {
            return this.name;
            }
        public int getAge() {
            return this.age;
            }
    }


    package nn;
    
    public class CRL {
        public static void main(String args[]) {
            RL r1 = new RL("张三",30);
            RL r2 = new RL("张三",30);
            if(r1.compare(r2)) {
                System.out.println("r1和r2");
                System.out.println("是同一个人");
            }
        }
    
    }



    package nn;
    
    public class ren {
        private int age;
        private String name;
        public ren(String name,int age) {
            this.name =name;
            this.age =age;
        }
        public boolean compare(ren l) {
            if(this==l) {
                return true;
            }
            if(this.name.equals(l.name)&&this.age==l.age) {
                return true;
                
            }else {
                return false;
            }
        }
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
        }
    
    }




    package nn;
    
    public class lei {
    
        public static void main(String args[]) {
            ren l1 = new ren("张三",20);
            ren l2 = new ren("张三",20);
            if(l1.compare(l1)) {
                System.out.println("是同一个人");
            }
            
    
        }
    
    }


    package nn;
    class ee {    
            private String name;
            private int age;
            public ee(String name,int age) {
                this.name = name;
                this.age = age;
            }
            public void fun(ee te) {
                te.name ="lucy";
                te.age =23;
            }
            public String getName() {
                return this.name;
            }
            public int getAge() {
                return this.age;
            }
        }


    package nn;
    
    public class Cdmo {
    
        public static void main(String args[]) {
            ee son =new ee("tony",22);
            son.fun(son);
            System.out.println(son.getName() + "-->" +son.getAge());
    
        }
    
    }


    package nn;
    public class qq {
        private String name;
        private String age;
        public qq(String name,String i){
            this.name=name;
            this.age=i;
        }
        public qq(String name2,int i) {
            
        }
        public String getName() {
            return this.name;
        }
    
        public String getAge() 
        {
            return this.age;
        }
    }
     
    package nn;
    public class sdf {
        public static void main(String args[]){
            qq per1 = new qq("理想",21);
            qq per2 = new qq("理想",21);
            {
                System.out.println("是同一个人!!");
            }   
        }
    };
    
    

    
    
  • 相关阅读:
    react注意事项
    小程序的页面滚动
    calc
    写好的vue项目怎么打包成uniapp形式
    处理其他系统过来的token.
    解析token
    iframe接受不同域名的token
    tree懒加载的使用,
    js防抖节流
    vue2.0和vue3.0的区别
  • 原文地址:https://www.cnblogs.com/luhan7/p/7825893.html
Copyright © 2020-2023  润新知