I noticed you are creating an Integer object here. One tip that may prove useful would be to use the Integer.parseInt() method. This would save you creating this Integer object as it is not in use in the rest of your code. eg:
The problem is that Exception block is never reach .. If you want to print that you can do like this
In your previous code,the catch exception is in the other method but as soon as the statement Integer iv=new Integer(args); is reached it throws an Exception in the main class..it do not go to the method that you are using so thats why its was not printing wat you want...
Better way is
You can do all you checking in the main class then call you method test if everything is ok. Anyway this is just an opinion of mine ...
[ July 17, 2007: Message edited by: vanlalhmangaiha khiangte ]
If in the method there is no catch statement and if the main statement has the catch statement then it will propagate and the catch block in the main will be execute.
If in the method there is specific catch statement for that exception then the catch block of the method will be execute not the catch block of main.
If there is catch block in method,but nothing is specific to that exception and there is a specific catch block for that exception in the main then that specific catch block in the main will be execute [ July 17, 2007: Message edited by: vanlalhmangaiha khiangte ]