InetAddress address = InetAddress.getByName("www.google.com"); String ipAddress = address.getHostAddress(); System.out.println(ipAddress); // prints the IP address of google.com
InetAddress address = InetAddress.getByName("216.58.194.174"); String hostname = address.getHostName(); System.out.println(hostname); // prints the hostname of the IP address
InetAddress address = InetAddress.getByName("www.google.com"); boolean isReachable = address.isReachable(5000); System.out.println(isReachable); // prints whether google.com is reachable within 5 secondsThe package library for java.net InetAddress is java.net.