size(): This size string javascript method in java returns the number of elements in TreeMap. Its return type is int.
int size();
import java.util.TreeMap; public class ExampleOfTreeMap { public static void main(String[] args) { TreeMap<Integer, String> listOfNames = new TreeMap<Integer, String>(); listOfNames.put(1, "JAVA"); listOfNames.put(2, "GOAL"); listOfNames.put(3, "RAVI"); System.out.println("Size of list = "+listOfNames.size()); } }
Output: Size of list = 3