How can we print wwwwwwww(inside system.out.println) because when it get exception it jumps to catch. class Account{ public static void main(String[] args) {String accn=null; try{ int i = 1%0; System.out.println("wwwwwww"); } catch(Exception e){
You can't. The other line in your program will throw a java.lang.ArithmeticException. What are you trying to achieve? Do you want to do something regardless of exceptions? If so have you come across finally blocks?
Isint that the point of a try catch, that if an exception is found in the try part it stops executing at the point of the exception, ignoring any code after the exception and "jumping" to the catch block.
So really there is no way to execute code in tehtry block after the exception occurs.
However if you had code that you always wanted to execute no matter if there is an exception or not, you could try putting it in to a finally block, you know:
We've found that when people use their real name as their display name things stay a lot friendlier, so I'd ask you to update your display name to match the JavaRanch policy.
Thanks, and welcome to the ranch.
Bert
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, that will fit in a stocking