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.
1 - It's a bad pattern to compare a boolean with true/false like that: "scan.hasNext() == true"
Explanation: if the variable is a boolean, doesn't need "== true"
2 - If you have to do a loop that uses the return of a boolean method (like "scan.hasNext()"), prefer to use while.
Explanation: Your code is more beautifull and readable. Clean code is a good practice.
Help this helps you
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 →
1 - It's a bad pattern to compare a boolean with true/false like that: "scan.hasNext() == true" Explanation: if the variable is a boolean, doesn't need "== true"
2 - If you have to do a loop that uses the return of a boolean method (like "scan.hasNext()"), prefer to use while. Explanation: Your code is more beautifull and readable. Clean code is a good practice.
Help this helps you