Online Java Compiler By
JavaTpoint.com
import java.net.URL; import java.util.Scanner; public class UrlgetProtocolExample1 { public static void main(String args[])throws Exception { //passing url in constructor URL url1=new URL("https://www.javatpoint.com/URL-class"); System.out.println("Url: "+url1); // Getting protocal used in given url System.out.println("Protocol used in given url is : "+url1.getProtocol()); } }
Output