0

What's wrong with my code?

What making this an infinite loop? https://code.sololearn.com/c8T8p84Fqgwv

24th Oct 2020, 3:09 PM
Manoj Kumar
Manoj Kumar - avatar
3 Answers
+ 2
There's no class, your code only contains a method. Please tag Java rather than the code link up there 👍
24th Oct 2020, 3:23 PM
Ipang
+ 1
Thank you @Ipang! By the way, whole code is bit longer that's why I only posted a method! All I want to know is what's making it an infinite loop?
25th Oct 2020, 10:18 AM
Manoj Kumar
Manoj Kumar - avatar
+ 1
Manoj Kumar I just checked your code again by pasting it in an empty class. It works, no infinite loop. I don't think you need <FinalReversedNumber>. You can do boolean <isNegative> = <number> less than zero If <isNegative> <number> = Math.abs(<number>) while() ... If isNegative return reversedNumber * -1 Else return reversedNumber
25th Oct 2020, 10:33 AM
Ipang