Tutorialspoint

Get Size of Java LinkedHashSet

import java.util.*;
public class Demo {
   public static void main(String[] args) {
		LinkedHashSet<Integer> set = new LinkedHashSet<Integer>();
		set.add(10);
		set.add(20);
		set.add(30);
		set.add(40);
		set.add(50);
		set.add(60);
		System.out.println("LinkedHashSet elements...");
		System.out.println(set);
		System.out.println("Size: "+set.size());
   }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.