I have two classes. One(Person) for getters and setters, and another(People) for compute the data. What is my situation is, I get the data from the DB using ResultSet
, then created a person Object to store the row data. Then i created people Object to store all persons.
Each Object created as SET.
while(rs.next())
{
Set<People> people = new HashSet<people>();
Person person = new Person();
String name = rs.getString(2);
person.setName(name);
int id = rs.getInt(1);
person.setId(id);
String dept = rs.getString(4);
person.setDept(dept);
int age = rs.getInt(3);
person.setAge(age);
people.add(person);
}
return people;
Now the problem is the last line in the While Loop people.add(person);
It says
The method add(People) in the type Set is not applicable for the arguments (Person)
How can i overcome this problem?
Thanks.