« Back
package com.collection.programs; import java.util.HashSet; class Employee{ int age; String name; public Employee(int age, String name) { super(); this.age = age; this.name = name; } @Override public String toString() { return "Employee [age=" + age + ", name=" + name + "]"; } } public class DemoHashSet { public static void main(String[] args) { // TODO Auto-generated method stub java.util.HashSet
h =new java.util.HashSet
(); Employee e1 = new Employee(1,"coder"); Employee e2 = new Employee(1,"arts"); Employee e3 = new Employee(1,"com"); h.add(e1); h.add(e2); h.add(e3); System.out.println(h); } }
[Employee [age=1, name=arts], Employee [age=1, name=coder], Employee [age=1, name=com]]
×
Report a Problem:
Description:
Submit