Java – How to get size of SortedSet

Size of SortedSet can be find by size() method. In size method, it will return value in integer.

Example of finding size in SortedSet in Java

SortedSet<String> ss=new TreeSet<String>();

ss.add("a");
ss.add("e");
ss.add("g");
ss.add("b");
ss.add("c");

int sizeOfSortedSet=ss.size();

System.out.println("Size of SortedSet :"+sizeOfSortedSet);

Output

Size of SortedSet :5

Tags:

Bookmark  

 

Leave a Reply

Security Code:

 

  Random Post