URLEquality.java Source code

Java tutorial

Introduction

Here is the source code for URLEquality.java

Source

import java.net.MalformedURLException;
import java.net.URL;

public class URLEquality {

    public static void main(String args[]) {

        try {
            URL sunsite = new URL("http://www.java2s.com");
            URL helios = new URL("http://www.demo2s.com");
            if (sunsite.equals(helios)) {
                System.out.println(sunsite + " is the same as " + helios);
            } else {
                System.out.println(sunsite + " is not the same as " + helios);
            }
        } catch (MalformedURLException e) {
            System.err.println(e);
        }

    }

}