Decode string to integer : Convert from String « Data Type « Java






Decode string to integer

  
 
public class Main {
  public static void main(String[] args) {
    String decimal = "10"; // Decimal
    String hexa = "0XFF"; // Hexa
    String octal = "077"; // Octal

    Integer number = Integer.decode(decimal);
    System.out.println("String [" + decimal + "] = " + number);

    number = Integer.decode(hexa);
    System.out.println("String [" + hexa + "] = " + number);

    number = Integer.decode(octal);
    System.out.println("String [" + octal + "] = " + number);
  }
}

   
    
  








Related examples in the same category

1.Parse a number using a NumberFormat
2.Convert from String to integer
3.Pass a string to the Integer class constructor and call the intValue()
4.Parse and format a number to octal
5.Parse and format a number to decimal
6.Parse and format to hexadecimal
7.Parse and format to arbitrary radix <= Character.MAX_RADIX
8.Convert string to an integer or number
9.Validate if string is a number
10.Declaring Checked Exceptions
11.Converting a String to a byte Number
12.Converting a String to a short Number
13.Converting a String to a int(integer) Number
14.Value Of Demo