这是标准:
这是代码:
import java.net.InetAddress;
import java.net.UnknownHostException;
public class NsLookup {
private InetAddress inet = null;
public void resolve(String host) {
try {
inet = InetAddress.getByName(host);
System.out.println("Host name : " + inet.getHostName());
System.out.println("IP Address: " + inet.getHostAddress());
}
catch (UnknownHostException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
NsLookup lookup = new NsLookup();
lookup.resolve(args[0]);
}
}
请尽可能帮我举例说明?
答案 0 :(得分:6)
实例化某些东西就是创建该类型的对象。你这样做:
NsLookup lookup = new NsLookup();
在这里:
inet = InetAddress.getByName(host);
希望这有所帮助,祝你好运!