Java - Numbers Class-parseInt() Method - Java

Description

This method is used to get the primitive data type of a certain String. parseXxx() is a static method and can have one argument or two.

Syntax

Following are all the variants of this method −

Parameters

Here is the detail of parameters −

  • s − This is a string representation of decimal.
  • radix − This would be used to convert String s into integer.

Return Value

  • parseInt(String s) − This returns an integer (decimal only).
  • parseInt(int i) − This returns an integer, given a string representation of decimal, binary, octal, or hexadecimal (radix equals 10, 2, 8, or 16 respectively) numbers as input.

Example

This will produce the following result −

Output

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java Topics