Mega Code Archive

 
Categories / Java Tutorial / Network
 

Compare two InetAddresses

import java.net.InetAddress; public class MainClass {   public static void main(String args[]) throws Exception {     InetAddress ca = InetAddress.getByName("www.google.ca");     InetAddress com = InetAddress.getByName("www.google.com");     if (ca.equals(com)) {       System.out.println("same");     } else {       System.out.println("not the same");     }   } } not the same