PDA

View Full Version : help required


Jimsta
10-11-2003, 04:18 AM
Hi all
I can't compile the code(listed below) succesfully because apparently it cannot reslove symbol, in regards to the getLocalHost() method in the java.net package and when I checked the package, i found the method there. Could anyone please inform me on where i might have gone wrong ?

import java.net.*;


class InetAddress
{

public static void main(String args[]) throws UnknownHostException {
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
Address = InetAddress.getByName("osborne.com");
System.out.println(Address);
InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for(int i=0;i<SW.length;i++)
{
System.out.println(SW[i]);
}
}
}

sans-hubris
10-11-2003, 10:46 AM
You shouldn't name a class the same name as a pre-packaged class, or else the compiler is going to look within your class rather the pre-packaged Java class. Name the class something else and it should work.