This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is getInteger for?

 
Arthur Clarke
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody.
Can anyone explain what are
public static Integer getInteger(String nm)
public static Integer getInteger(String nm, int val) for?
In Java 2 SDK, Standard Edition Documentation I have read this:
getInteger determines the integer value of the system property with the specified 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 null is returned.
I have tested on my computer (OS -Windows 98) this program:
import java.util.*;
class Test {
public static void main(String[] args) {
Properties prop = new Properties();
prop = System.getProperties();
for(Enumeration enum = prop.propertyNames(); enum.hasMoreElements(); ) {
System.out.println(Integer.getInteger((String)enum.nextElement()));
}
}
}
The result was a list of null-s.
So if all integer value of the system property are null what are getInteger for?
Thank you very much. :roll:
[ October 02, 2002: Message edited by: ArthurClarke ]
[ October 02, 2002: Message edited by: ArthurClarke ]
[ October 02, 2002: Message edited by: Arthur Clarke ]
[ October 02, 2002: Message edited by: Arthur Clarke ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ArthurClarke,
Welcome to Javaranch
We'd like you to read the Javaranch Naming Policy and change your publicly displayed name (change it here) to comply with our unique rule. Thank you.
PS: Quote from the naming policy:

For your publicly displayed name, use a first name, a space, and a last name. Obviously fictitious names or improperly formatted names may be locked out.

PS: Adding a space between Arthur and Clarke would be perfect
 
Vin Kris
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means there are no properties in your environment that can be represented by an Integer. Try passing an optional parameter, say -DTEST=5
 
Arthur Clarke
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Vin Kris.
It works!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic