• 第十一次 判断是否同一个人


    public class Shiyi {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            new Shiyi().fun();
        }
        public void fun()
        {
            System.out.println("Hello World!!!");
        }
    }









    public class Shier {
        String name;int age;
        public Shier(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Shier 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
            Shier per1 = new Shier("xy",20);
            Shier per2 = new Shier("xy",20);
            if(per1.compare(per2)){
                System.out.println("这俩人一个样~");
            }
        }
    }




    public class Shisan {
        String name;int age;
        public Shisan(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Shisan per) {
            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
            Shisan per1 = new Shisan("xy",20);
            Shisan per2 = new Shisan("xy",20);
            if(per1.compare(per2)){
                System.out.println("这俩人是同一个~");
            }
        }
    }




        class Person {
        private String name;
        private int age;
        public Person(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public void fun(Person temp) {
            temp.name = "ktt";
            temp.age = 18;
        }
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
        }
    public static class Shisi {
        public static void main(String args[]) {
            // TODO Auto-generated method stub
            Person per = new Person("xy",20);
            per.fun(per);
            System.out.println(per.getName() + "-->" + per.getAge());
            }
        }
    }





    class Pe {
        private String name;
        private int age;
        public Pe(String name,int age) {
           this.name = name;
           this.age = age;
       }
       public String getName() {
           return this.name;
       }
       public int getAge() {
           return this.age;
       }
    }
    public  class Shiwu {
       public void main(String args[]) {
           Pe per1 = new Pe("xy",20);
           Pe per2 = new Pe("xy",20);
           if(per1.getName().equals(per2.getName())&&per1.getAge()==per2.getAge()) {
               System.out.println("这两人是一个样~");
           }
       }
    }
    
    
    
    
  • 相关阅读:
    Android_Studio常用插件
    Android_Studio 及SDK下载
    Ubuntu 16.04 LTS 正式发布:系统将持续更新5年
    Windows通用应用平台
    Jquery局部打印插件
    WEB打印插件Lodop
    WEB打印插件jatoolsPrinter
    hdu1863
    PromiseKit入门
    高速排序
  • 原文地址:https://www.cnblogs.com/jingjing1314/p/7865887.html
Copyright © 2020-2023  润新知