| Author |
Extracting INT value from a STRING
|
Brett Swift
Ranch Hand
Joined: May 22, 2002
Posts: 61
|
|
I'm trying to figure out how to extract an int value from the command line. It came up in my head as something you'd think to be fundamental, but I can't figure it out!?! I've tried parseInt(args[0]); valueOf(args[0]); but maybe I've got the syntax wrong. (not too familiar with those methods.. probably using them wrong!) Anyone have any tips? Thanks! Brett
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
pareInt is a static method of Integer, so just use this: That should do the trick. Of course, you'll probably want to catch a NumberFormatException (which is a runtime exception) in the case that the first argument isn't a valid int. Corey
|
SCJP Tipline, etc.
|
 |
Brett Swift
Ranch Hand
Joined: May 22, 2002
Posts: 61
|
|
thanks.. I now remember having this problem before and all it was ....was forgeting to reference the Integer class in front of the method call! Thanks!
|
 |
 |
|
|
subject: Extracting INT value from a STRING
|
|
|