package 第十次; 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!!!"); } }
package 第十次; 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("这俩人一个样~"); } } }
package 第十次; 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("这俩人是同一个~"); } } }
package 第十次; 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()); } } }
package 第十次; 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("这两人是一个样~"); } } }
最新评论