Write a java program to print the ip address. This is a Java program that displays the system’s IP address. An Internet Protocol address is represented by the InetAddress class. To get the IP address string in textual format, we use this class’s getHostAddress() method. Here is the source code for the Java program that displays the system’s IP address.
public class Main
public static void main(String args) throws Exception
InetAddress IP = InetAddress.getLocalHost();
System.out.println("IP address= "+IP.getHostAddress());
IP address 000.000.000.000
What is IP address in computer
What is INET address in java program
The InetAddress class contains methods for obtaining the IP address of any host name, such as www.noteshippo.com, www.google.com, www.facebook.com, and so on. A 32-bit or 128-bit unsigned number is used to represent an IP address. The IP address and its accompanying host name are represented by an instance of InetAddress.
The Java InetAddress class’s getLocalHost() function returns an instance of InetAddress with the local host name and address. First, the system’s host name is retrieved, and then that name is resolved into InetAddress.