views:

87

answers:

2

I am go through a socket program. In that printStackTrace is caught by the catch block. Actully what it is?

    catch(IOException ioe)
    {
        ioe.printStackTrace();
    }

I am unaware of it. For what they are used?

+1  A: 

It prints the stack trace of the Exception to System.err.

It's a very simple, but very useful tool for diagnosing an Exception. It tells you what happened and where in the code this happened.

Joachim Sauer
I think by default it prints to `System.err`.
Ash
Of course, thanks.
Joachim Sauer
And thanks to checked exceptions it's probably the #1 content of `catch` blocks :-)
Joey
A: 

Learn Java and you will get answer for your question :)

Andriy Sholokh
I think SO is a good place to learn Java, by asking questions of course.
nimcap