+ 2

is printStackTracr() method working or not???

It's not showing anything about in the catch block i.e printStackTrace()... isn't it supposed to print the exception details??? here's the code:- class A { public static void main (String args[]) { try { for(int i=0;i<3;i++) { System.out.println("hello"); Thread.sleep(1000); } } catch(InterruptedException ie) { ie.printStackTrace();} } }

4th Sep 2017, 8:04 AM
Saurav Kumar
Saurav Kumar - avatar
3 Answers
+ 2
thanks that helps me alot
5th Sep 2017, 7:57 AM
Saurav Kumar
Saurav Kumar - avatar
+ 2
thanks it was really helpful
5th Sep 2017, 9:49 AM
Saurav Kumar
Saurav Kumar - avatar
+ 1
but one more question.... if that code not throws any exeception than why we use try/catch.... however if we not use try/catch than it will.show that interrupted exception!! so .. what exactly happens with InterruptedException exception??... is it get solved within try block? which I think not!!! maybe I am wrong... please tell
5th Sep 2017, 8:04 AM
Saurav Kumar
Saurav Kumar - avatar