Reputation: 41
I want a user to input an integer and then convert the number. How do I tell Java that the input integer is base 8? As, I can't append a '0' to the front of an integer variable.
Upvotes: 0
Views: 170
Reputation: 41
Thanks for the suggestion. I figured it out. The answer I was looking for lies in the javadoc for the Scanner class.
Upvotes: -1
Reputation: 1249
Integer.parseInt("20", 8);
will treat the input as octal. In general, the second parameter is the base.
Upvotes: 3