Compare two urls in java

Compare two urls in java

package com.w3spoint;
 
import java.net.MalformedURLException;
import java.net.URL;
 
public class URLTest {
  public static void main(String args[]){
	try {
	    URL url1 = new URL("https://www.w3spoint.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 Share