Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java exception

    - 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

Java Exceptions - Try...Catch

public class Main {
  public static void main(String[ ] args) {
    try {
      int[] myNumbers = {1, 2, 3};
      System.out.println(myNumbers[10]);
    } catch (Exception e) {
      System.out.println("Something went wrong.");
    }
  }
}
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

exception in java

In java exception is an object. Exceptions are created when an abnormal 
situations are arised in our program. Exceptions can be created by JVM or 
by our application code. All Exception classes are defined in java.lang. 
In otherwords we can say Exception as run time error. 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

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 :: linked list vs vector 
Java :: osmdroid get current zoom level 
Java :: how to add main and laucher activity in android manifest 
Java :: java convert double to boolean 
Java :: android studio Toast usage 
Java :: default case in Java switch-case 
Java :: do function after time android studio 
Java :: implements java 
Java :: how to remove scroll pane border 
Java :: how to call a non static method 
Java :: dependency injection java 
Java :: how to know if a file is iso-8859-1 encoded in java 
Java :: java words from file 
Java :: how to translate java swing 
Java :: how to add data into list model in android 
Java :: Implement the static keyword – static variable, static block, static function and static class with following conditions 
Java :: mettre caractère de string en majuscule java 
Java :: jhow to check if a string is a punctuation java 
Java :: string to words java 
Java :: get sum of array and return string 
Java :: java create array 
Java :: how to get string value in java in android 
Java :: how to compare doubles in java 
Java :: java double 
Java :: java.lang.classcastexception: java.lang.string cannot be cast to java.util.arraylist 
Java :: set style programmatically android 
Java :: java change hashmap value 
Java :: edittext editable false android java 
Java :: get string size 
Java :: Java Enum compareTo() 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =