Latest web development tutorials

Java parseInt () method

Java Number classes Java Number classes


parseInt () method is used to string argument as a signed decimal integer resolution.

If the method has two parameters, the second argument specifies the radix, Parses the string argument as a signed integer.

grammar

All derived classes Number parseInt method similar to the following format:

static int parseInt(String s)

static int parseInt(String s, int radix)

parameter

  • s - the string representation of a decimal.

  • radix - Specifies the base.

return value

  • parseInt (String s): Returns the integer value represented by the argument in decimal.

  • parseInt (int i): the specified base string argument is an integer (the base may be 10, 2, 8, 16, etc., or decimal).

Examples

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 classes Java Number classes