I have read so many article as on difference between isEmpty()
and size()
> 0 for check that collection
is empty or not and found that isEmpty()
have perfomance over size()
but I could not understand easily why perfomance of isEmpty()
is good even though inside isEmpty() is only size == 0 ?
My questions are :
Can any one explain easily in which scenario
isEmpty()
is faster as well as when to useisEmpty()
andsize()
function for checking ifcollection
isempty
or not?Can any one explain this, using code or other way(Diagrams,graphs etc) so that any beginner can understand easily?