what changes should be applied on the code
code:
import java.net.*;import java.util.*;public class IPFinder { public static void main(String[] args) { String host; Scanner input = new Scanner(System.in); System.out.print("\n\nEnter host name: "); host = input.next(); try { InetAddress address = InetAddress.getByName(host); System.out.println("IP address:" + address); System.out.println("Host Address:" + address.getHostAddress()); System.out.println("Is this Address Multicast? : " + address.isMulticastAddress()); // returns address in bytes System.out.println("IP Address in bytes : " + address.getAddress()); } catch (UnknownHostException uhEx) { System.out.println("Could not find " + host); } }}
import java.net.*;
import java.util.*;
public class IPFinder
{
public static void main(String[] args)
{
String host;
Scanner input = new Scanner(System.in);
System.out.print("\n\nEnter host name: ");
host = input.next();
try {
InetAddress address = InetAddress.getByName(host);
System.out.println("IP address:" + address);
System.out.println("Host Address:" + address.getHostAddress());
System.out.println("Is this Address Multicast? : "
+ address.isMulticastAddress());
// returns address in bytes
System.out.println("IP Address in bytes : "
+ address.getAddress());
}
catch (UnknownHostException uhEx)
{
System.out.println("Could not find " + host);
}
}
}
Enter host name: www.amazon.com IP address :www.amazon.com/54.192.1.31 Host Address : 54.192.1.31 Is this Address Multicast?: false IP Address in bytes : [B@ 42 a57993
what changes should be applied on the code code: import java.net.*;import java.util.*;public class IPFinder { public s
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am