Results 1 to 2 of 2
Thread: ParseInt question
- 03-09-2009, 08:56 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 47
- Rep Power
- 0
ParseInt question
static int parseInt(String s)
Parses the string argument as a signed decimal integer.
If I put in, for example, "1" and "hey" the program gives me a number format exception. I thought parseint returned the string AS an int? If so, why does it give me an exception?Java Code:public class Divider { public static void main(String args[]) { try{ System.out.println("Before divison"); int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); System.out.println(i/j); System.out.println("After divison"); } catch(ArithmeticException e) { System.out.println("Arithmetic Exception"); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Array Index Out Of Bounds Exception."); } catch(NumberFormatException e) { System.out.println("Number Format Exception"); } finally { System.out.println("Finally block"); } } }
- 03-09-2009, 09:34 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
[SOLVED] Integer.parseInt() problem
By eggmanpete in forum New To JavaReplies: 18Last Post: 02-15-2009, 04:25 PM -
parseInt() vs. intValue()
By JavaPilot in forum New To JavaReplies: 5Last Post: 02-04-2009, 08:39 AM -
Integer.parseInt?
By Exhonour in forum New To JavaReplies: 4Last Post: 01-20-2009, 02:31 AM -
Problem with Integer.parseInt()
By Hevonen in forum New To JavaReplies: 2Last Post: 12-14-2008, 03:41 AM -
[SOLVED] Command Line Arguments and ParseInt
By Sophiie in forum New To JavaReplies: 4Last Post: 11-16-2008, 09:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks