BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Java Integer getInteger() Method

Last Updated: October 24, 2022 by Chaitanya Singh | Filed Under: java

The getInteger() method of Integer class, returns the integer value of the system property with the specified property name.

Hierarchy:

java.lang Package
    -> Integer Class
        -> getInteger() Method

Syntax of getInteger() method

There are three variations of getInteger() method. Let’s discuss them one by one. This first variation accept a single String name nm, which represents the property name.

If there is no property with the specified name, if the specified name is empty or null, or if the property does not have the correct numeric format, then it returns null.

public static Integer getInteger(String nm)

Second variation of this method with String and int arguments:

public static Integer getInteger(String nm, int val)

Third variation of this method with String and Integer arguments:

public static Integer getInteger(String nm, Integer val)

getInteger() Parameters

  • nm – Property name.
  • val – Default value. This value is returned if the specified property does not exist.

getInteger() Return Value

  • The Integer value of the property.

Supported java versions: Java 1.2 and onwards.

Example 1: Method getInteger(String nm)

public class JavaExample {
  public static void main(String[] args) {
    String str = "java.vendor.url";
    System.out.println("Integer Value: "+Integer.getInteger(str));

    str = "os.arch";
    System.out.println("Integer Value: "+Integer.getInteger(str));
  }
}

Output:

Java Integer getProperty Output

Example 2: Method getInteger(String nm, int val)

public class JavaExample {
  public static void main(String[] args) {
    String str = "java.vendor.url";
    System.out.println("Integer Value: "+Integer.getInteger(str));
    System.setProperty(str, "101");
    System.out.println("Integer Value: "+Integer.getInteger(str));

    String str2 = "custom.property";
    System.out.println("Integer Value: "+Integer.getInteger(str2, 200));
  }
}

Output:

Integer getProperty method in Java

Example 3: Method getInteger(String nm, Integer val)

public class JavaExample {
  public static void main(String[] args) {
    String str = "custom.property.1";
    Integer i = new Integer(100);
    System.out.println("Integer Value: "+Integer.getInteger(str, i));
    String str2 = "custom.property.2";
    Integer i2 = new Integer(1000);
    System.out.println("Integer Value: "+Integer.getInteger(str2, i2));
  }
}

Output:

Integer getProperty Ex Output

Recommended Posts

  • Java Integer floatValue()
  • Java Integer equals()
  • Java Integer doubleValue()
  • Java Integer divideUnsigned()
❮ Java Integer

Top Related Articles:

  1. Java Integer byteValue() Method
  2. Java String charAt() Method example
  3. Java – String regionMatches() Method example
  4. Java String substring() Method with examples
  5. Static and dynamic binding in java

Tags: Integer

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Java Tutorial

Java Introduction

  • Java Index
  • Java Introduction
  • History of Java
  • Features of Java
  • C++ vs Java
  • JDK vs JRE vs JVM
  • JVM - Java Virtual Machine
  • First Java Program
  • Variables
  • Data Types
  • Operators

Java Flow Control

  • Java If-else
  • Java Switch-Case
  • Java For loop
  • Java while loop
  • Java do-while loop
  • Continue statement
  • break statement

Java Arrays

  • Java Arrays

OOPs Concepts

  • OOPs Concepts
  • Constructor
  • Java String
  • Static keyword
  • Inheritance
  • Types of inheritance
  • Aggregation
  • Association
  • Super Keyword
  • Method overloading
  • Method overriding
  • Overloading vs Overriding
  • Polymorphism
  • Types of polymorphism
  • Static and dynamic binding
  • Abstract class and methods
  • Interface
  • Abstract class vs interface
  • Encapsulation
  • Packages
  • Access modifiers
  • Garbage Collection
  • Inner classes
  • Static import
  • Static constructor

Java Exception Handling

  • Exception handling
  • Java try-catch
  • Java throw
  • Java throws
  • Checked and Unchecked Exceptions
  • Jav try catch finally
  • Exception Examples
  • Exception Propagation

Collections Framework

  • Collections in Java
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Java HashSet
  • Java LinkedHashSet
  • Java TreeSet
  • Java HashMap
  • Java TreeMap
  • Java LinkedHashMap
  • Java Queue
  • Java PriorityQueue
  • Java Deque
  • Comparable interface
  • Comparator interface
  • Collections Interview Questions

MORE ...

  • Java Scanner Class
  • Java 8 Features
  • Java 9 Features
  • Java Conversion
  • Java Date
  • Java Multithreading
  • Java I/O
  • Java Serialization
  • Java Regex
  • Java AWT
  • Java Swing
  • Java Enum
  • Java Annotations
  • Java main method
  • Java Interview Q

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap