Home » Java Basics » exceptions

exceptions

Java Custom Exception Example

In this example we will look briefly at the basics of Exception, in Java Programming Language. We will also see, how to create a custom Exception Class. 1. Basics of Exception As per oracle docs, An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions. In laymen terms, when ...

Read More »

java.lang.SecurityException – How to solve SecurityException

In this tutorial we will discuss about SecurityException in Java. This exception is thrown by the security manager, in order to indicate a security violation. The SecurityException class extends the RuntimeException class and thus, belongs to those exceptions that can be thrown during the operation of the Java Virtual Machine (JVM). It is an unchecked exception and thus, it does ...

Read More »

java.util.InputMismatchException – How to solve InputMismatchException

In this tutorial we will discuss about the InputMismatchException in Java. This exception is thrown by an instance of the Scanner class to indicate that a retrieved token does not match the pattern for the expected type, or that the retrieved token is out of range. The InputMismatchException class extends the NoSuchElementException class, which is used to indicate that the ...

Read More »

java.lang.NoSuchFieldError – How to solve SuchFieldError

In this tutorial we will discuss about the NoSuchFieldError in Java. This exception is thrown to indicate that an application tries to access or modify an object’s field, but that field no longer exists. This error can only occur during runtime, if the definition of a class has incompatibly changed. The NoSuchFieldError extends the IncompatibleClassChangeError class, which is used to ...

Read More »

java.lang.ArrayStoreException Example

In this example we will discuss about ArrayStoreException. This exception is thrown when there has been made an attempt to store the wrong type of object into an array of objects. The ArrayStoreException extends RuntimeException, which means that it is an exception thrown at the runtime, so the try-catch block for this exception is not required. ArrayStoreException exists since JDK1.0. ...

Read More »

java.lang.StringIndexOutOfBoundsException – How to solve StringIndexOutOfBoundsException

In this tutorial we will discuss about the java.lang.StringIndexOutOfBoundsException in Java. This exception is thrown by the methods of the String class, in order to indicate that an index is either negative, or greater than the size of the string itself. Moreover, some methods of the String class thrown this exception, when the specified index is equal to the size ...

Read More »

java.lang.VerifyError – How to solve VerifyError

In this tutorial we will discuss about the VerifyError in Java. This error indicates that the verifier, included in the Java Virtual Machine (JVM), detected a class file that despite well formed, it contains some type of internal inconsistency or faces a security problem. The VerifyError class extends the LinkageError class, which is used to indicate those error cases, where ...

Read More »

java.lang.IncompatibleClassChangeError – How to resolve Incompatible Class Change Error

In this example we will discuss about IncompatibleClassChangeError. This is thrown when an incompatible class change has occurred to some class definition. The definition of some class, on which the currently executing method depends, has since changed. It is normally thrown when a non-final field of a base class becomes static, or when the base class turns into an interface ...

Read More »

java.lang.AbstractMethodError – How to resolve Abstract Method Error

In this example we will discuss about AbstractMethodError. As you may have figured out, this is thrown when the application calls an abstract method. Normally, this error is caught by the compiler, it can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled. The AbstractMethodError extends the ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns