In this example we will show how to use java default URL object.
Source Code
package com.beginner.examples;
import java.net.MalformedURLException;
import java.net.URL;
public class URLExample {
public static void main(String[] args) throws MalformedURLException{
String example = "https://www.yahoo.com/";
URL url = new URL(example);
System.out.println(url.toString());
}
}
Output:
https://www.yahoo.com/
References
Imported packages in Java documentation: