The only way I know to do it is to parse the string to an int and compare for greater than zero. Of course, you'd have to deal with an IllegalArgumentException in case the String is not parsable to an int...
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
You could just use the ABS method to return the absolute value of the interger.
Joined: Jul 30, 2003
But if you do that you accept negative values. In other words, if the user is supposed to enter the number of widgets on shelf 5 of the factory storeroom, and enters "-5", do you really want your program to translate that to "5"?
Joined: Sep 14, 2004
Well if you just want them to enter a postive value, which i dont know why they would be entering negtive anyway, you could check the integer for being < 0, if so loop back around to the input and send a message to enter postive only.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com