Core Java Tutorials


Introduction

Java Hello World

Java Compilation

JDK New Features

JVM Architecture

Java OOPs Concepts

Java Package

Array

Exception Handling

String

Immutable Class

File Handling

Serialization

MultiThreading

Volatile

Concurrent Package

Collection

Collection Internal

Generics

Cloning

Reflection In Java

Annotation

Class Loader

Java Inner classes

Garbage Collector

JDBC

References In Java

Heap Dump & Thread Dump

Error Exception in Java

Error and Exception in java are very common in java programming. Most of the time exception are caused by our program and programmer can handle it using exception handling.
A Java Exception is an object that describes the exception that occurs in a program. When any exception occurs during execution of the java program then this exception must be thrown either by JRE or Java Programmer. The code which responsible exception handling is called an exception handler. So in Java Exceptions are those runtime errors which program can handle it using try and catch block. These exceptions can be language define exception or programmer define business exception.

  What is Error?

Error is also an exception which comes at runtime in java program. But error can not be handled since this comes if enough resources are not there or some important classes are missing(not in classpath) at runtime. if program writes try and catch to handle this kind of error then it does not make sense. Errors are also unchecked exception.
Example :- If OutOfMemoryError occurs then program will terminate abnormally since we cannot increase memory at runtime. Other Examples : NoClassDefFoundError, VirtualMachineError, IncompatibleClassChangeError, UnsatisfiedLinkError etc.

  Difference Between Exception & Error :
error-exception-in-java

  Example of Error :
stack-over-flow-error> <br />

<hr/>
 <span class=   Example of Error :
incompatable-changes

  Difference between Exception & Error :
class-not-fond-exception