Create url object with properties in java

package com.w3spoint;
 
import java.net.MalformedURLException;
import java.net.URL;
 
public class URLTest {
  public static void main(String args[]){
	try {
	    String protocol = "https";
            String host = "w3spoint.com";
            int port = 8080;
            String path = "/object-oriented-design-principles-in-java-examples/";
            URL url = new URL(protocol, host, port, path);
            System.out.println(url.toString());
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
  }
}

Output

https://www.w3spoint.com:8080/object-oriented-design-principles-in-java-examples/
Please Share