In this program we will find ip address by using InetAddress class present in java.net package. Method getLocalHost() prints the ip of your local machine while method getByName() prints the ip of a particular url. Also Read: Java Program to Find Union of two Arrays
Program:-
import java.net.*; class FindIP { public static void main(String...s)throws Exception { System.out.println(InetAddress.getLocalHost()); System.out.println(InetAddress.getByName("www.google.com")); } }
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.