- This is a Java Program to Display the IP Address of the System.
- InetAddress class represents an Internet Protocol (IP) address. We use the method named getHostAddress() of this class to get the IP address string in textual presentation.
- Here is the source code of the Java Program to Display the IP Address of the System. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.net.InetAddress;
public class IP_Address
{
public static void main(String args[]) throws Exception
{
InetAddress IP = InetAddress.getLocalHost();
System.out.println("IP of my system is := "+IP.getHostAddress());
}
}
Output:
IP of my system is := 127.0.1.1
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.