public class Z { public static void main(String[] args) { // TODO Auto-generated method stub new Yi().fun(); } public void fun() { System.out.println("Love is a carefully designed lie. "); } }
public class Z { String name;int age; public Z (String name,int age) { this.name = name; this.age = age; } public boolean compare(K 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 Z per1 = new Z ("1",18); Z per2 = new Z ("1",18); if(per1.compare(per2)){ System.out.println("这俩人一个样~"); } } }
public class Z { String name;int age; public Z(String name,int age) { this.name = name; this.age = age; } public boolean compare(Z 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 T per1 = new Z("1",18); T per2 = new Z("1",18); 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 = "1"; temp.age = 18; } public String getName() { return this.name; } public int getAge() { return this.age; } public static class Z { public static void main(String args[]) { Person per = new Person("11"17); per.fun(per); System.out.println(per.getName() + "-->" + per.getAge()); } } }
class Z { 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 Z { public void main(String args[]) { Pe per1 = new 1("Z",18); Pe per2 = new 2("Z",18); if(per1.getName().equals(per2.getName())&&per1.getAge()==per2.getAge()) { System.out.println("她们是同一个人!!"); } } }