Friday, 6 May 2016

Java collection# set quiz

Today I am going to demonstrate you the property of set with the small code snippet.
Set set=new hashset();
This is illegal.
You may ask why why it is illegal.
The answer is we have added items belonging to completely different data types.
so when internally set calls sort operation it cannot perform sort operation on completely different data types.
That's why we can not add items of different data type in the set.

For Java training please drop mail to:

Labels: , , ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home