4

Error and RuntimeException both are the unchecked exception. Which one should I extend while creating custom unchecked exception? Though both are logically different , but if my only purpose of extending them is to create unchecked exception , does it really matters which one i extend ? Also I am not sure but performance vice both should be same , i guess.

P.S. I have idea about difference between Error and Exception.

Priyank Doshi
  • 12,895
  • 18
  • 59
  • 82

1 Answers1

7

Extend RuntimeException. Error is generally used only internally by the JVM, to signal situations (e.g. out of memory) from which you can not recover.

See the Java Language specification (11.1) for more details

Flavio
  • 11,925
  • 3
  • 32
  • 36