0

I have referred many books and even Java docs provided by Oracle but still I have a confusion that what makes Error class different from Exception class. Can you guys please explain this as we can catch and handle both.

class Handle{
     public static void main(String args[]){
         try{
             int k = 10/0;
         }catch(Exception e){
         }
         try{
             //some statement
         }catch(Error e){
         }
     }
}
Harshit Gupta
  • 719
  • 1
  • 9
  • 26

1 Answers1

2

It's a semantic difference. An Error is something that is impossible to survive from (think OutOfMemoryError), whereas an Exception could possibly be handled somehow.

Kayaman
  • 72,141
  • 5
  • 83
  • 121