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("是同一个人!");
    		}
    	}
    }
    

      

  • 相关阅读:
    const变量指针赋值给非const类型的指针运行结果
    嵌套结构可以访问外部结构的私有成员吗?
    几种cms的介绍
    中国互联网网站尴尬排行榜[转]
    如何跨域来同步不同网站之间的Cookie
    CMS整站程序整理
    vs 设置断点
    ASP.NET 4中的SEO改进
    VSS演示
    发生一个未处理的异常 脚本调试 错误号2912
  • 原文地址:https://www.cnblogs.com/chengxuyuanGM/p/7802949.html
Copyright © 2011-2022 走看看