There are three different types of Java getInteger() methods which can be differentiated depending on its parameter. These are:
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.
Following is the declaration of getInteger(String nm) method:
| DataType | Parameter | Description | Required/Optional |
|---|---|---|---|
| String | nm | It is the system property name from which we get the value as an integer object. | Required |
The getInteger(String nm) method will returns the value of the property specified as method argument as an Integer object.
NA
Java 1.2 and above
Output:
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
Output:
Default property: 64 Custom Property: 100
Output:
Enter the desired input string: sun.arch.data.model Default Value = 64 Custom Value = null
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.
Following is the declaration of getInteger(String nm, int val) method:
| DataType | Parameter | Description | Required/Optional |
|---|---|---|---|
| String | nm | It is the system property name from which we get the value as an integer object. | Required |
| Int | val | It is the default value specified by user which returned if property were not found. | Required |
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.
NA
Java 1.2 and above
Output:
102 999
Output:
System Property: 123 Default property: 64 Custom Property:100 Custom Property: 124
Output:
Enter the desired system property: sun.arch.data.model Default Value: 64 Custem Value: 25
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.
Following is the declaration of getInteger(String nm, Integer val) method:
| DataType | Parameter | Description | Required/Optional |
|---|---|---|---|
| String | nm | It is the system property name from which we get the value as an integer object. | Required |
| Integer | val | It is the deafult value specified by user which returned if property were not found. | Required |
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.
NA
Java 1.2 and above
Output:
133 Default property:64 Custom Property: 100 Custom Property: 105
Output:
Enter the desired System Property name: sun.arch.data.model System Property Value: 64 Custom Value: 25
Output:
102 950
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India