• Finally : 1 step to handle all errors

    In all advance level exception handling, all programmer use finally keyword to prevent run time error. Let’s take one example: User-1 transfers amount to another User-2 account. Amount withdraws from User-1 and suddenly some hardware or networking error generated. That time finally block removes all transfer amounts.   Example on Finally in exception handling class […]

  • IOException with BufferedReader class

    IOException is on run time input output exception handler, when we use java.io.* package’s classes that time we have to use IOException for handling error. BufferedReader is one inbuilt class. BufferedReader class must be in java.io.* package so we have to import that package in our program starting. In this program, we will see how […]

  • IllegalAccessException with throws

    In this blog, we will work on IllegalAccessException using throws keywords. This example is same as NullPointerException using throw keyword. Using this example we can understand basic different between throws and throw.   Example on IllegalAccessException class A {             void setMethod1() throws IllegalAccessException             {                                   // No need to try and catch block […]

  • Custom Exceptions using throw keyword

    Maximum MNC company create own structure code. In this structure code they also create Custom Exceptions handling classes, methods and constructors. In this blog example, we create LoginException exception for check login details of admin panel.   LoginException : Custom Exceptions import java.util.*;                   class LoginException extends Exception {             LoginException(String errorMessage)             {                         super(errorMessage);           […]

  • NullPointerException – Handle by throw

    NullPointerException is run time error, when we display object and do not find any value in object. In this blog, we will see how this exception handles by throw keyword.   This example and video work on throw keyword. class A {             void method1()             {                         try                         {                                     //throw new NullPointerException(“Error […]

  • Trace-run time error using try catch keywords

    In this blog, we will see 2 programs. 1st program is not handled and other is handled run time error. Using of these 2 programs we can understand trace-run time error. 1st – program [Trace-run time error] class Exc5 {             static void method1(int x,int y)             {                         int div = x/y;                           System.out.println(“Div […]

  • 1 try – multiple catch handling

    1 try – multiple catch handling is maximum use program in java. In this example we will work on ArrayIndexOutOfBoundsException, ArithmeticException and normal Exception. Here we create one try block with three catch block with three different run time errors.   Let’s see 1 try – multiple catch program with videos   class Exc4 { […]