Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java parseInt() Method

Java parseInt() Method

Java Number ClassThe Java Number class


The parseInt() method parses a string argument as a signed decimal integer.

If the method has two arguments, the string argument is parsed as a signed integer using the radix specified by the second argument.

Syntax

The parseInt method format for all Number-derived classes is similar to the following:



static int parseInt(String s)



static int parseInt(String s, int radix)

Parameters

Return Value

Example



public class Test{

    public static void main(String args[]){

        int x =Integer.parseInt("9");

        double c = Double.parseDouble("5");

        int b = Integer.parseInt("444",16);



        System.out.println(x);

        System.out.println(c);

        System.out.println(b);

    }

}

Compile the above program; the output is:



9

5.0

1092


Java Number ClassThe Java Number class