Java Integer getInteger() Method22 Feb 2025 | 5 min read There are three different types of Java getInteger() methods which can be differentiated depending on its parameter. These are:
1. Java Integer getInteger(String nm) Method:The getInteger(String nm) method is a method of Integer class under java.lang package. This method determines the integer value of the system property with the specified name of method argument. If there is no property with the specified name of method argument, if the specified name is empty or null or if the property does not have the correct numeric format, it will returned null. Syntax:Following is the declaration of getInteger(String nm) method: Parameter:
Returns:The getInteger(String nm) method will returns the value of the property specified as method argument as an Integer object. Exceptions:NA Compatibility Version:Java 1.2 and above Example 1Output: sun.arch.data.model is the Java System property which determines the version of the JVM is used - 32 or 64bit. Value = 64 Value = null Example 2Output: Default property: 64 Custom Property: 100 Example 3Output: Enter the desired input string: sun.arch.data.model Default Value = 64 Custom Value = null 2. Java Integer getInteger(String nm, int val) Method:The getInteger(String nm, int val) method is a method of Integer class under java.lang package. This method determines the integer value of the system property with the specified name of method argument. The first argument is treated as the name of a system property. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned. The second argument is the default value. An Integer object that represents the value of the second argument is returned if there is no property of the specified name, if the property does not have the correct numeric format, or if the specified name is empty or null. Syntax:Following is the declaration of getInteger(String nm, int val) method: Parameter:
Returns:The getInteger(String nm, int val) method returns the value of the system property name specified as method argument as an Integer object and if not found, the default value will be returned as specified by the user. Exceptions:NA Compatibility Version:Java 1.2 and above Example 1Output: 102 999 Example 2Output: System Property: 123 Default property: 64 Custom Property:100 Custom Property: 124 Example 3Output: Enter the desired system property: sun.arch.data.model Default Value: 64 Custem Value: 25 3. Java Integer getInteger(String nm, Integer val) Method:The getInteger( String nm, Integer val ) method is a method of Integer class under java.lang package. This method determines the integer value of the system property with the specified name of method argument. The first argument is treated as the name of a system property. System properties are accessible through the System.getProperty(java.lang.String) method. The string value of this property is then interpreted as an integer value and an Integer object representing this value is returned.
The second argument is the default value. This value is returned if there is no property of the specified name, if the property does not have the correct numeric format, or if the specified name is empty or null. Syntax:Following is the declaration of getInteger(String nm, Integer val) method: Parameter:
Returns:The getInteger(String nm, Integer val) method returns the value of the system property name specified as method argument as an Integer object and if not found, the default value will be returned as specified by the user. Exceptions:NA Compatibility Version:Java 1.2 and above Example 1Output: 133 Default property:64 Custom Property: 100 Custom Property: 105 Example 2Output: Enter the desired System Property name: sun.arch.data.model System Property Value: 64 Custom Value: 25 Example 3Output: 102 950 Next TopicPackage-class |
In the realm of digital entertainment, games have always held a special place, captivating audiences with their immersive experiences and engaging gameplay. One technology that has played a significant role in the development of countless games is Java. Known for its versatility, portability, and extensive libraries,...
4 min read
In this section, we will learn what is an Adam number and also create Java programs to check if the given number is Adam or not. The Adam number program frequently asked in Java coding tests and academics. Adam Number A number is called an Adam number if...
3 min read
The java.nio.DoubleBuffer has a limit() function. The DoubleBuffer Class is utilized to adjust the limit of this DoubleBuffer. This method sets the new limit of this buffer by using the parameter, which is the limit to be set. This new limit is not set and...
3 min read
The N-th Stair Problem, also known as the Stair Climbing Problem. It is a classic dynamic programming challenge. The problem generally asks: Considering a staircase, how many different ways can you climb to the top? If you can only climb one or two stairs at a...
7 min read
The XOR bitwise operator, indicated by the symbol "^", is a binary operator in Java that performs a bitwise XOR operation between two operands. The XOR operation returns a value in which each bit in the result is set to 1 if and only if precisely...
3 min read
In Java, objects of a subclass can be referenced using either a subclass reference or a superclass reference. The difference lies in what methods or fields can be accessed and how the behavior of the program changes depending on the reference type. Referring to Subclass Objects in...
5 min read
In Java, when working with multi-threaded applications, it is crucial to manage thread priorities effectively. Prioritizing threads can help us to control how the operating system schedules threads for execution. Java provides a method called setPriority() to set the priority of a thread, allowing us to...
9 min read
So far, we have focused on objects in Java. Since Java 8, more importance is given to the functional aspects of programming. JavaSoft people realized that doing everything using objects is becoming cumbersome and using functions can be more efficient in certain cases. Lambda expression...
4 min read
In computational problems, finding the largest rectangle in a binary matrix is a classic problem that tests one's understanding of dynamic programming and stack-based approaches. The problem is often encountered in various fields, such as image processing, computer vision, and even game development. In this...
6 min read
Java code structure and organization rely significantly on packages and interfaces. They are working in various circumstances and for different purposes. We will explore the fundamental concepts behind Java packages and interfaces in this article. Both packages and interfaces act as a kind of container....
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India