You are viewing a single comment's thread. Return to all comments →
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.
Can you explain how complexity is differed between those loops ??
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
Thanks that was really helpful!