I have tried obtaining my computer's IP address in two different ways. The first way was to just Google ip address
. The second way was to run the following code in Java:
public class YourIPAddress {
public static void main(String[] args) {
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
System.out.println(ip);
System.out.println("Current IP address : " + ip.getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
}
Google returns 50.90.142.29
whereas Java returns 192.168.0.11
. Why this conflict in IP addresses?