Skip to content
Algorithms
  • Home
  • IDE
  • Site Map
  • Difficulty Level
    • Beginner
    • Intermediate
    • Expert
  • Interviews
    • Amazon Questions
    • Goldman Sachs
    • Google Interview
    • Microsoft Interview
    • Apache
    • NetApp
    • Adobe
    • Facebook
    • NVIDIA
    • Oracle

Print My IP Address – Java Code

September 1, 2019July 31, 2018 by Sumit Jain

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

Related Posts:

  • Print All Paths in Dijkstra's Shortest Path Algorithm
  • Print Number with its Sign in Java
  • Print all Unique elements in a given array
  • Java Program to determine if Given Year is Leap Year
  • Find Factorial of a given Number
  • Generate all the strings of length n from 0 to k-1.
  • Print all substrings of a given string
  • Print all nested directories and files in a given directory - Recursion
  • Print Numbers from 1 to N without using loop
  • Print maximum occurring character in a String
  • Java Pair Class
  • Print First N Prime Numbers - Java Code
  • Print all subarrays using recursion
  • Print all middle elements of the given matrix/2D array.
  • Check if Given Number is power of 2.
Categories Beginner, Java Concepts, MISC Tags Beginner Leave a comment
Post navigation
Find the Circumference of a Circle – Java Program
Print First N Prime Numbers – Java Code

Leave a Comment Cancel reply

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



More Problems

  • Java Pair Class
  • Print First N Prime Numbers - Java Code
  • Print all subarrays using recursion
  • Print all middle elements of the given matrix/2D array.
  • Check if Given Number is power of 2.
  • Fizz Buzz Challenge - Java Implementation
  • Product of all Unique elements in a given array.
  • Print boundary of given matrix/2D array.
  • Deque Implementation – Java
  • Java Program to find if Triangle can be formed using given 3 sides




Subscribe ( No Spam!!)

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,414 other subscribers

Recent Posts

  • Non-decreasing Array with one allowed change
  • Duplicate zero’s without expanding the array.
  • Maximum Depth of Valid Nested Parentheses
  • Decimal to Binary
  • Maximum Consecutive Ones
  • Duplicate even elements in an array
  • Minimum Increments to make all array elements unique
  • Add digits until number becomes a single digit
  • Maximum Surpasser in the given array
  • Find the number of pairs with odd XOR






© 2021 Algorithms • Powered by GeneratePress