Example & Tutorial understanding programming in easy ways.

Can a null element added to a Treeset or HashSet?

A null element can be added only if the Set contains one element because when a second element is added then as per set definition a check is made to check duplicate value and comparison with null element will throw NullPointerException.

HashSet is based on HashMap and can contain null element.

Read More →
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!