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