This example returns IP address of your PC.
Play Free Online Games and Win Big Prize Money
-Watch video
https://youtu.be/sX0XAROhuiQ
Play Free Online Games and Win Big Prize Money
-Watch video
https://youtu.be/sX0XAROhuiQ
import java.net.*;
public class TellMyIP {
public static void main(String[] args) {
InetAddress localHostIP= null;
//creates instance of InetAddress
try{
localHostIP=InetAddress.getLocalHost();
//initializes localHostIP
System.out.println("IP ADDRESS OF MY PC IS = "+localHostIP.getHostAddress());
//gets IP address and prints it
}catch (Exception exception){
System.out.println("Something that went wrong is :"+exception.getMessage());
}
}
}
Watch video