How to Handle Exceptions Without Catch Blocks in Java


The example is to show how to handle exceptions without catch blocks in Java.

Source Code

package com.beginner.examples;

import java.net.MalformedURLException;
import java.net.URL;
 
public class HandleExceptionExample {
    public static void main(String[] args) throws MalformedURLException{
    	URL url = new URL("https://www.yahoo.com/");
        System.out.println(url);
    }
}

Output:

https://www.yahoo.com/

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments