java - Differences in Queue methods -


why queue have 2 different methods each retrieving element , removing element?

retrieving methods: element() , element peak() removing methods: element poll() , element remove()

what difference between them (except return-type differences in first case)?

you should read javadoc queue:

remove():

retrieves , removes head of queue. this method differs poll in throws exception if queue empty.

element():

retrieves, not remove, head of queue. this method differs peek in throws exception if queue empty.

(emphasis mine.)


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -