Java Integer.getInteger(String nm, int val)

Syntax

Integer.getInteger(String nm, int val) has the following syntax.

public static Integer getInteger(String nm,   int val)

Example

In the following code shows how to use Integer.getInteger(String nm, int val) method.


public class Main{
   public static void main(String[] args) {
     String myKey = "MyKey";
     System.setProperty(myKey, "102");
     System.out.println(Integer.getInteger(myKey));
     System.out.println(Integer.getInteger("NoExist",999));
   }//from   ww  w. j a  va  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