aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is getInteger for? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is getInteger for?" Watch "What is getInteger for?" New topic
Author

What is getInteger for?

Arthur Clarke
Greenhorn

Joined: Aug 22, 2002
Posts: 9
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

Joined: Aug 26, 2001
Posts: 7610
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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Vin Kris
Ranch Hand

Joined: Jun 17, 2002
Posts: 154
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

Joined: Aug 22, 2002
Posts: 9
Thank you, Vin Kris.
It works!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is getInteger for?