Hello All,
I am having some troubles with my code, which is:
import java.net.*;
import java.io.*;
class TestInet
{
public static void main(String args[])
{
try{
InetAddress inet = InetAddress.getByName("72.14.203.106");
InetAddress inet1 = InetAddress.getLocalHost();
InetAddress inet2[] = InetAddress.getAllByName("www.google.com");
//InetAddress inet3 = InetAddress.getHostName();
System.out.println ("Host of IP is[inet.getByName]: " + inet.getHostName());
System.out.println("Localhost is[inet.getLocalHost]: " + inet1);
for(int a = 1; a < inet2.length; a++)
{
System.out.println("IPs of google are[i.getAllByName]: " + inet2[a]);
}
inetCheck();
//System.out.println("Localhost is[inet.getHostName]: " + inet3);
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void inetCheck()
{
InetAddress inet3 = InetAddress.getHostName();
System.out.println("Localhost is[inet.getHostName]: " + inet3);
}
}
Its giving three errors;
1)non-static method initCheck() cannot be referenced from static context (line 24)
2)non-static method getHostName() cannot be referenced from static context (line 36)
3)incompatible types:
found:java.lang.string
required: java.lang.inetAddress (line 36)
The second thing I'm not getting is getByName("72.14.203.106"), I thought it would return Host name, but it's giving me some irksome values like "tx-in-f106.1e100.net"
So what's this basically doing ??
Hope to see your help soon.
Regards!