Home  • Programming • Java

Java program to get ip address

This program prints IP or internet protocol address of your computer system. InetAddress class of java.net package is used, getLocalHost method returns InetAddress object which represents local host. Code
import java.net.InetAddress;
 
class IPAddress
{
   public static void main(String args[]) throws Exception
   {
      System.out.println(InetAddress.getLocalHost());
   }
}
Compile and Run 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.

Comments 0


Share

Copyright © 2024. Powered by Intellect Software Ltd