hello group members sir i want to know abt exception handling in java 1.what is diffrence between finally and catch is it similar to desturctor like fianlize ? 2.why always run finally if exception not occur? 3.clear me the meaning of implement runnable class through thread
Ok, those are some pretty different questions you have there...
The finally clause is what you want to execute whether or not an exception occurs. Like if you have opened a stream and you're reading bytes, then whether or not there's an exception (something goes wrong), you still want to try to close the stream, so you put that in the finally clause.
1.what is diffrence between finally and catch is it similar to desturctor like fianlize ?
Finalize is not a destuctor as we have in C++ but it does give a programmer the last chance to do anything before an object is lost..Garbage collected It also provides the programmer the a chance to ressurest the object i.e recreate the same ..but this can only be doen once.
As regards to threads You may create threads by either extending the thread class or Implementing the runnable interface both of which will provide arun method through which you can do your Processing