0
[Solved] Why doesnât this work?
Iâve worked on this for an hour. Hoping for an answer. ââ Update: Still has some problems. ââ Update: Solved. https://code.sololearn.com/cqJ9oJvCjR6Q/?ref=app
2 Answers
+ 6
Albert Tan
What is the use of setInt and main method in Converter class? Doesn't make sense if there is toBinary method.
And what is the use of dec parameter in toBinary method?
This is enough:
public static String toBinary(int num) {
String binary = "";
while (num > 0) {
binary = (num % 2) + binary;
num /= 2;
}
return binary;
}
+ 1
Thanks!