+ 4
Integer.parseInt() is used to extract an integer value from a String. I.E. "42" You can pass a second argument to get a particular radix (base) for that integer string value. public class Program { public static void main(String[] args) { String num = "42"; // default Decimal base 10 String bin = "101010"; // Binary base 2 String oct = "052"; // Octal base 8 (byte) String hex = "2A"; // Hexadecimal base 16 System.out.println(Integer.parseInt(num)); System.out.println(Integer.parseInt(bin, 2)); System.out.println(Integer.parseInt(oct, 8)); System.out.println(Integer.parseInt(hex, 16)); } } https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt-java.lang.String-
30th Oct 2017, 2:49 AM
ChaoticDawg
ChaoticDawg - avatar