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:
retrieves , removes head of queue. this method differs poll in throws exception if queue empty.
retrieves, not remove, head of queue. this method differs peek in throws exception if queue empty.
(emphasis mine.)
Comments
Post a Comment