Java program to get IP address
Java program to print the IP (Internet Protocol) address of a computer system, we use InetAddress class of java.net package, the getLocalHost method returns InetAddress object, which represents the localhost.
Java IP address program
import java.net.InetAddress;
class IPAddress
{
public static void main(String args[]) throws Exception
{
System.out.println(InetAddress.getLocalHost());
}
}
Output of program:
The output shows the computer name/ IP address of the computer. Java has a very vast Networking API, which can be used to develop network applications.