I still always incapable to to improve it or understand your ideas
return (id == ((Employee) obj1).getId() || name.equals(((Employee) obj1).getName()))
I thought it is enough since whatever if...
Type: Posts; User: vector_ever
I still always incapable to to improve it or understand your ideas
return (id == ((Employee) obj1).getId() || name.equals(((Employee) obj1).getName()))
I thought it is enough since whatever if...
Now what the next, any advanced help??
I put it
@Override
public boolean equals(Object obj1){
if(!(obj1 instanceof Employee))
return false;
return (id == ((Employee) obj1).getId() ||...
and how you suggest to use equal() method to give me the desired result, what should i add in my equal and Hashcode methods?
return (id == ((Employee) obj1).getId() || name.equals(((Employee) obj1).getName()));
means if, either id or name are duplicated in any object then don't add them in the HashSet
On this basis,...
ok for example i want to make compare as the following: if the ID or name is Duplicate in any object dann must not be added
@Override
public boolean equals(Object obj1){
...
i know that i must do so, but i don't know how
i added this part in Employee.java Class and it works
@Override
public boolean equals(Object obj){
if(!(obj instanceof Employee))
return false;
...
Hello;
as known HashSet store no duplicated values Unlike ArrayList, anyway i tried to make example to store Objects in HashSet and the result show it take Duplicated values
import...