what is parseint in java

11 months ago 40
Nature

parseInt() is a method in Java that is used to parse a string value as a signed decimal value and convert it to an integer. It belongs to the Integer class which is under the java.lang package. The method can be declared in Java using the following syntax:

  • public static int parseInt(String s)
  • public static int parseInt(String s, int radix)
  • public static int parseInt(CharSequence s, int beginText, int endText, int radix)

The first variant of the method parses the string argument as a signed decimal integer object. The second variant parses the string argument as a signed decimal integer object in the specified radix by the second argument. The third variant parses the CharSequence argument as a signed integer in the specified radix argument, beginning at the specified beginIndex and extending to endIndex - 1 .

The parseInt() method is a static method, which means that it can be called without creating an Integer object first.