Size of SortedMap can be find by size() method. In size method, it will return value in integer.
Example of finding size in SortedMap in Java
SortedMap<Integer,String> sm=new TreeMap<Integer, String>();
sm.put(new Integer(2), "Two");
sm.put(new Integer(1), "One");
sm.put(new Integer(4), "Four");
sm.put(new Integer(3), "Three");
sm.put(new Integer(5), "Five");
int sizeOfSortedMap=sm.size();
System.out.println("Size of SortedMap :"+sizeOfSortedMap);
Output
Size of SortedMap :5
Tags: Collections




Link to Us