Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java standard exceptions

    - ArithmeticException 
    It is thrown when an exceptional condition has occurred in an arithmetic operation.
    
    - ArrayIndexOutOfBoundsException 
    It is thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
    
    - ClassNotFoundException 
    This Exception is raised when we try to access a class whose definition is not found
    
    - FileNotFoundException 
    This Exception is raised when a file is not accessible or does not open.
    
    - IOException 
    It is thrown when an input-output operation failed or interrupted
    
    - InterruptedException 
    It is thrown when a thread is waiting, sleeping, or doing some processing, and it is interrupted.
    
    - NoSuchFieldException 
    It is thrown when a class does not contain the field (or variable) specified
    
    - NoSuchMethodException 
    It is thrown when accessing a method which is not found.
    
    - NullPointerException 
    This exception is raised when referring to the members of a null object. Null represents nothing
    
    - NumberFormatException 
    This exception is raised when a method could not convert a string into a numeric format.
    
    - RuntimeException 
    This represents any exception which occurs during runtime.
    
    - StringIndexOutOfBoundsException 
    It is thrown by String class methods to indicate that an index is either negative or greater than the size of the string
Comment

exceptions you get in java

Unchecked:
-IndexOutOfBounds exception(while working with arrays/strings)
-NullPointerException(if I forget to instantiate the objects)
-ArithmaticException

Checked:
-IOException
-SQLException
-FileNotFountException
Comment

exception handling in java

public class JavaExceptionExample{  
  public static void main(String args[]){  
   try{  
      //code that may raise exception  
      int data=100/0;  
   }catch(ArithmeticException e){System.out.println(e);}  
   //rest code of the program   
   System.out.println("rest of the code...");  
  }  
}  
Comment

how do you handle exceptions in java

I use try & catch blocks to handle any exceptions in my code. 
  I am familiar with major checked and unchecked exceptions and 
  handle it accordingly to make my code execution smooth
Comment

PREVIOUS NEXT
Code Example
Java :: insert node at end of doubly linked list 
Java :: springboot validator manually validate 
Java :: one key with multiple values map java 
Java :: declaring java variables 
Java :: POST method) in spring rest api 
Java :: java long literal 
Java :: how to remove an element from an arraylist java 
Java :: method overloading 
Java :: why string is immutable in java 
Java :: java unicode characters 
Java :: java convert int to string 
Java :: spring mongodb 
Java :: convert python to java 
Java :: int to integer array in java 
Java :: Java public no-arg constructor 
Java :: madrid 
Java :: control flow graph generator 
Java :: java method overloading 
Java :: youtube to mp4 stackoverflow 
Java :: java.lang.NullPointerException: Cannot store to double array because is null 
Java :: prime numbers most efficient algorithm java 
Java :: java %2C 
Java :: java try-with-resources nested streams 
Java :: springBoot Register a Custom Auto-Configuration 
Java :: pattern exercises for java 
Java :: find maximum number of rides in amusement park python 
Java :: setvisibility not working in fragment 
Java :: java how to slit a dtring and trim at the same time 
Java :: jwt token in android studio 
Java :: Cloudinary image Transformation in Java 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =