1
2 int decimalExample = Integer.parseInt("20");
3 int signedPositiveExample = Integer.parseInt("+20");
4 int signedNegativeExample = Integer.parseInt("-20");
5 int radixExample = Integer.parseInt("20",16);
6 int stringExample = Integer.parseInt("geeks",29);
7
8 // Uncomment the following code to check
9 // NumberFormatException
10
11 // String invalidArguments = "";
12 // int emptyString = Integer.parseInt(invalidArguments);
13 // int outOfRangeOfInteger = Integer.parseInt("geeksforgeeks",29);
14 // int domainOfNumberSystem = Integer.parseInt("geeks",28);
15
16 System.out.println(decimalExample);
17 System.out.println(signedPositiveExample);
18 System.out.println(signedNegativeExample);
19 System.out.println(radixExample);
20 System.out.println(stringExample);
21
22Output:
23
2420
2520
26-20
2732
2811670324
29