What is '10' doing there? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is '10' doing there?

int num = 5542; String number = String.valueOf(num); for(int i = 0; i < number.length(); i++) { int j = Character.digit(number.charAt(i), 10); System.out.println("digit: " + j); } Asking about the 10 in line 4. I guess it's converting char into int..but am no sure!

20th Aug 2019, 11:59 AM
Amit Dubey
Amit Dubey - avatar
2 Answers
+ 1
I think it's used to convert it to particular number system => 10 is for decimal, 2 is for binary number etc.
20th Aug 2019, 12:09 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
Yea, 10 is converting 'j' in base 10 i.e equal to j but in an integer form. Got it, thanks anyways TheWh¡teCat
20th Aug 2019, 12:33 PM
Amit Dubey
Amit Dubey - avatar