adsense


Showing posts with label JAVA EXAMPLES RUNTIME EXCEPTIONS. Show all posts
Showing posts with label JAVA EXAMPLES RUNTIME EXCEPTIONS. Show all posts

Thursday, 29 October 2015

JAVA EXAMPLES RUNTIME EXCEPTIONS PAGE 126

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES RUNTIME EXCEPTIONS





Java Examples - Runtime Exceptions


Problem Description:
How to handle runtime exceptions?
Solution:
This example shows how to handle the runtime exception in a java programs.
public class NeverCaught {
   static void f() {
      throw new RuntimeException("From f()");
   }
   static void g() {
      f();
   }
   public static void main(String[] args) {
      g();
   }
}
Result:
The above code sample will produce the following result.
From f()