TreeMap Size
import java.util.Map;
import java.util.TreeMap;
class Test implements Comparable{
int a;
Test(int a){
this.a = a;
}
@Override
public int compareTo(Object arg0) {
return this.a - ((Test)arg0).a;
}
}
public class TreeMapTest {
public static void main(String[] args){
Test t1 = new Test(1);
Test t2 = new Test(1);
Map<Test,Integer> map = new TreeMap<>();
map.put(t1, 1);
map.put(t2, 1);
System.out.println("Size="+map.size());
}
}
OUTPUT
Size=1