source file name:  InetAddressDemo.java

import java.io.*;  

import java.net.*;  

 class InetAddressDemo

{  

public static void main(String[] args)

{  

try

{  

InetAddress ip1=InetAddress.getByName("sjnprogramming.blogspot.com");  

InetAddress ip2=InetAddress.getLocalHost(); 

InetAddress[] ip=InetAddress.getAllByName("www.yahoo.com");   

System.out.println("Host Name: "+ip1.getHostName());  

System.out.println("IP Address: "+ip1.getHostAddress());  

System.out.println("IP Address of local computer: "+ip2);  

System.out.println("IP Addresses of ");  

for(int i=0;i<ip.length;i++)

System.out.println(ip[i]);


}

catch(Exception e)

{System.out.println(e);}  

}  

}  

output:

D:\JavaPrograms\Networking>javac InetAddressDemo.java

D:\JavaPrograms\Networking>java InetAddressDemo

Host Name: sjnprogramming.blogspot.com

IP Address: 172.217.163.161

IP Address of local computer: Indian-PC/192.168.42.148

IP Addresses of

www.yahoo.com/202.165.107.49

www.yahoo.com/202.165.107.50