error java code example

Example 1: rjava error

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_144')

Example 2: What is an error in Java

Error is the subclass of Throwable class in java. When errors are caused 
by our program we call that as Exception, but sometimes exceptions are 
caused due to some environment issues such as running out of memory. 
In such cases we can’t handle the exceptions. 
Exceptions which cannot be recovered are called as errors in java.
Ex : Out of memory issues

Example 3: exception java

1.Unchecked: occurs during run time
2.Checked Exceptions:occurs during the compile time. 
needs to be handled IMMEDIATELY
Exception handling: try & catch: blocks, used for handling the exception 
 
throws keyword is used within the method signature 
disadvantage is: throws keyword whoever calls the method 
will have to handle the exception again but with 
try/catch you handle once. Try/catch is better way to handle it 
in utility class. Next time you call method you don’t get any exceptions
 
most common Exception like NullPointerExceptio, 
ArrayIndexOutOfBound, ClassNotFoundException, IOException.
are unchecked and they are descended from java.lang.RuntimeException
In Selenium: nosuchelement, nostaleexception, nosuchaframe 
In SQL: SQL exception

Tags:

Java Example