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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: