thanks for correcting me,I have read the article, so here is my questions
[Query]
Below I have written the immutable class, Please let me know
1) Whats wrong in my code
2) how may i test my immutable class
[/Query]
import java.util.*;
import java.util.Map.Entry;
public final class ImmutableTest {
private final int id;
private final String name;
private final HashMap<String, String> hm ;
public int getId() {
return id;
}
public String getName() {
return name;
}
public HashMap<String, String> getHm() {
return (HashMap<String, String> )hm.clone();
}
public ImmutableTest(HashMap<String, String> hm, int id, String name) {
super();
HashMap<String, String> temp = new HashMap<String, String>();
this.id = id;
this.name = name;
Set<Entry<String, String>> s = hm.entrySet();
Iterator<Entry<String, String>> itr = s.iterator();
while(itr.hasNext()){
Map.Entry<String, String> inentry = itr.next();
temp.put(inentry.getKey(), inentry.getValue());
}
this.hm=temp;
}
}
[B][/B]