zoukankan      html  css  js  c++  java
  • Java作业十(2017-11-8)

    public class TAutoPerson {
    	public static void main(String args[]) {
    		new TAutoPerson().fun();
    	}
    	public void fun() {
    		System.out.println("hello world!!!");
    	}
    }
    

      

    package com.baidu.www;
    
    public class Tperson {
        String name;int age;
        public Tperson(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Tperson 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
        	Tperson per1 = new Tperson("张三",30);
        	Tperson per2 = new Tperson("张三",30);
            if(per1.compare(per2)){
                System.out.println("是同个人!");
            }
        }
    }
    

      

    package com.baidu.www;
    
    public class Tperson {
        String name;int age;
        public Tperson(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public boolean compare(Tperson 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
        	Tperson per1 = new Tperson("张三",30);
        	Tperson per2 = new Tperson("张三",30);
            if(per1.compare(per1)){
                System.out.println("是同个人!");
            }
        }
    }
    

      

    package com.baidu.www;
    
    public class Tperson {
        String name;int age;
        public Tperson(String name,int age) {
            this.name = name;
            this.age = age;
        }
        public void fun(Tperson temp){
        	temp.name="李四";
        	temp.age=33;
        	}
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
    }
        public static void main(String[] args) {
        	Tperson per=new Tperson("张三",30);
    		per.fun(per);
    		System.out.println(per.getName()+per.getAge());
    }
    }
    

      

    package com.baidu.www;
    
    public class Tperson {
        String name;int age;
        public Tperson(String name,int age) {
            this.name = name;
            this.age = age;
        }
    
        public String getName() {
            return this.name;
        }
        public int getAge() {
            return this.age;
    }
        public static void main(String[] args) {
        	Tperson per1=new Tperson("张三",30);
        	Tperson per2=new Tperson("张三",30);
    		if(per1.getName().equals(per2.getName())&&per1.getAge()==per2.getAge()){
    		System.out.println("是同一个人!");
    		}
    	}
    }
    

      

  • 相关阅读:
    存储那些事儿(二): 下一代Linux文件系统BTRFS简介
    RabbitMQ消息队列的小伙伴: ProtoBuf(Google Protocol Buffer)
    RabbitMQ消息队列(七):适用于云计算集群的远程调用(RPC)
    RabbitMQ消息队列(六):使用主题进行消息分发
    C++内存管理之shared_ptr
    C++程序调试方式总结
    匿名对象?临时对象?
    C++多态中虚函数表合并与继承问题
    C++继承体系中的内存分段
    C++继承体系中的内存对齐
  • 原文地址:https://www.cnblogs.com/chengxuyuanGM/p/7802949.html
Copyright © 2011-2022 走看看