- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Size of Java LinkedHashSet
To get the size of LinkedHashSet, use the size() method.
First, set the LinkedHashSet and add elements −
LinkedHashSet<Integer> set = new LinkedHashSet<Integer>(); set.add(10); set.add(20); set.add(30); set.add(40); set.add(50); set.add(60);
Display the size of the LinkedHashSet created above −
set.size()
The following is an example to get the size of LinkedHashSet −
Example
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()); } }
Output
LinkedHashSet elements... [10, 20, 30, 40, 50, 60] Size: 6
- Related Articles
- Iterate through elements of Java LinkedHashSet
- Get Size of Java LinkedHashMap
- LinkedHashMap and LinkedHashSet in Java
- Get size of HashSet in Java
- Get Size of TreeSet in Java
- Remove specified element from Java LinkedHashSet
- Remove all elements from Java LinkedHashSet
- Fetch key-valuepair from Java LinkedHashSet
- Get the size of an ArrayList in Java
- Get the size of the IdentityHashMap in Java
- Difference Between LinkedList and LinkedHashSet in Java
- Copy all elements of Java LinkedHashSet to an Object Array
- Get the size of the LabelValue Tuple in Java
- Java Program to Get the Size of the Collection
- Get JFrame window size information in Java

Advertisements