why we need to throws exception when we can handle it by using try and catch... by using throw...
//A void method
public void sample()
{
//Statements
//if (somethingWrong) then
IOException e = new IOException();
throw e;
//More Statements
}
by using try and catch
MyClass obj = new MyClass();
try{
obj.sample();
} catch(IOException ioe)
{
//Your error Message here
System.out.println(ioe);
}
they work exactly same. what are the major differece between them.. plzz explain in POINTS....