Deloitte Interview Question

What happen if we add null in TreeSet. Give the logic.

Interview Answer

Anonymous

Jan 10, 2015

can be added if the treeset is empty because there is no object to compare with but throws null pointer exception if the ts is non empty since the comparison of null with non null object ref throws nullpointer exception.

1