Code:
SizeOfHashSet.java
|
package net.roseindia;import java.util.HashSet;public class SizeOfHashSet { public static void main(String[] arg) {HashSet obHashSet = new HashSet();obHashSet.add( new Integer(1));obHashSet.add( new Integer(2));obHashSet.add( new Integer(3));obHashSet.add( new Integer(4));System. out.println("All Elements in HashSet : " + obHashSet);System. out.println("Size of HashSet : " + obHashSet.size());} } |
|
All Elements in HashSet : [1, 2, 3, 4] Size of HashSet : 4 |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.