Java program to get ip address

Levels of difficulty: / perform operation:

This program prints IP or internet protocol address of your computer system. InetAddress class of package is used, getLocalHost method returns InetAddress object which represents local host.

This java program

class IPAddress {


Output of code prints computer name/ IP address of computer. Java has a very vast Networking API and can be used to develop network applications.