CodesJava

Easy learning with example program codes

Compare two urls in java

Compare two urls in java

package com.codesjava;
 
import java.net.MalformedURLException;
import java.net.URL;
 
public class URLTest {
  public static void main(String args[]){
	try {
	    URL url1 = new URL("https://codesjava.com");
            URL url2 = new URL("https://www.java.com");
            if(url1.equals(url2)){
                System.out.println("URLs are equal");
            } else {
                System.out.println("URLs are not equal");
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
  }
}

Output

URLs are not equal
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status