You are viewing a single comment's thread. Return to all comments →
Don't use for loops like that! :-)
What do you mean?
can you explain why ?
because in this case the time compkexity is more for the for loop that while loop
any link to explain/proof would be great.
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