/**
 class yang biasa pertama dibuat oleh programmer
 @author iman l hakim (milh_cbt@yahoo.com)
 
*/
import java.util.Set;
import java.util.HashSet;

public class Hello{

	/**
	ini methode yang pertama dipanggil oleh Java virtual machine JVM
	*/
	public static void main(String[] consoleIn){
	
	    Person andi = new Person (15,"Andi");
		Person yenni = new Person (14, "Yenni");
	    Person x = new Person(15, "Andi");	
		Set<Person> peserta = new HashSet<Person>();
		peserta.add(andi);
		peserta.add(yenni);
		peserta.add(x);
		System.out.println("equals : "+andi.equals(x));
		System.out.println("== : " + (andi == x) );
		System.out.println("hashcode andi:"+andi.hashCode());
		System.out.println("hashcode x:"+x.hashCode());
	}
}
class Person{
    public Person(int ID,String name){
		this.ID = ID;this.name = name;
	}
    public int ID;
	public String name;
	
	public boolean equals(Object o){
	    if ((o instanceof Person)== false) return false;
		Person other = (Person) o;
		
		if(this.ID == other.ID) return true;
		return false;
	}
	public int hashCode(){return ID;}
}


@@ -1,12 +1,62 @@
+%0Aimport java.util.Set;%0Aimport java.util.HashSet;%0A%0A
 /**%0A class y
@@ -148,57 +148,8 @@
 %0A*/%0A
-import java.util.Set;%0Aimport java.util.HashSet;%0A%0A
 publ
@@ -725,16 +725,78 @@
 ode());%0A
+%09%09for(Person p: peserta)%7BSystem.out.println(%22peserta:%5Cn%22+p);%7D%0A
 %09%7D%0A%7D%0Acla
@@ -923,16 +923,27 @@
 name;%0A%09%0A
+%09@Override%0A
 %09public 
@@ -1112,16 +1112,27 @@
 lse;%0A%09%7D%0A
+%09@Override%0A
 %09public 
@@ -1158,11 +1158,90 @@
 rn ID;%7D%0A
+%09@Override%0A%09public String toString()%7B%0A%09%09return %22ID: %22+ID+ %22%5Cn Nama: %22+name;%0A%09%7D%0A
 %7D%0A%0A

nambah to string