We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Because, the for loop check if the condition is true but scan.hasNext() is already boolean.
When scan.hasNext() return TRUE:
TRUE == TRUE -> TRUE
When scan.hasNext() return FALSE:
FALSE == TRUE -> FALSE
So you see, it's not necesary compare with other boolean.
Other example: the method isEmpty(Returns true if this list contains no elements.), We will mostly need to know when the collection contains elements, so we use it this way:
if(!myCollection.isEmpty()){//do something with the elements...}//Or we can compare with falseif(myCollection.isEmpty()==false){//do something with the elements...}
We simply deny it.
(Sorry my english)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java End-of-file
You are viewing a single comment's thread. Return to all comments →
Because, the for loop check if the condition is true but
scan.hasNext()
is already boolean.So you see, it's not necesary compare with other boolean.
Other example: the method isEmpty(Returns true if this list contains no elements.), We will mostly need to know when the collection contains elements, so we use it this way:
We simply deny it.
(Sorry my english)