Print My IP Address – Java Code

Objective: Write a java program to print your IP address.

Approach:

  • Get the local host address of your system using getLocalHost() method.
  • Use getHostAddress() method to get the IP address from local host address.

Code:


Output:

IP ADDRESS is : 192.162.1.9

__________________________________________________
Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

%d bloggers like this: