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

c# - HttpResponseMessage System.InvalidOperationException -

sql - Postgresql error: "failed to find conversion function from unknown to text" -