Problem statement: Given code is
Elements:
[A, B, C]
Size: 3
Objects: [A, B, C]
- public class Test {
- public static void main(String[] args) {
- HashSet<String> s = new HashSet<>();
- s.add("A");
- s.add("B");
- s.add("C");
- s.add("A");
- System.out.println("Elements: \n" + s);
- System.out.println("Size: " + s.size());
- System.out.println("Objects: " + s);
- }
- }
Elements:
[A, B, C]
Size: 3
Objects: [A, B, C]
No comments:
Post a Comment