Java Integer.valueOf(String s, int radix)

Syntax

Integer.valueOf(String s, int radix) has the following syntax.

public static Integer valueOf(String s,  int radix)   throws NumberFormatException

Example

In the following code shows how to use Integer.valueOf(String s, int radix) method.


public class Main{
   public static void main(String[] args) {
     System.out.println(Integer.valueOf("100",2));
     System.out.println(Integer.valueOf("100",8));
     System.out.println(Integer.valueOf("100",10));
     System.out.println(Integer.valueOf("100",16));
   }/*from ww w.j  a v a  2 s . c  o m*/
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable