Sid Name Per Stream
Sid Name Per Stream
Sid Name Per Stream
{
int sid;
String name;
double per;
String stream;
public Student(int sid, String name, double per, String stream)
{
this.sid = sid;
this.name = name;
this.per = per;
this.stream = stream;
}
@Override
public String toString()
{
return "Student [" + sid + "," + name + "," + per + "," + stream
+ "]";
}
public int hashCode()
{
return sid; // based on id
//return name.hashCode(); // based on Name
//return ((Double)per).hashCode(); // based on per
}
public boolean equals(Object obj)
{
return this.hashCode()==obj.hashCode();
}
}
import java.util.HashSet;
import java.util.Scanner;
System.out.println("<-----Students INFO----->");
for(Object obj:students)
{
System.out.println(obj);
}
}
}