[问题]Cannot find symbol

ShingU 2004-04-12 12:45:17
编译后的出错信息为:

symbol : method getHostAddress()
location: class java.net.InetAddress[]
System.out.println(name+"["+i+"] : "
+addr.getHostAddress()); ^

其他的定义:
String name = args[0];
InetAddress[] addr = InetAddress.getAllByName(name);

我是在看不懂到底哪里出问题了..?
...全文
262 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ShingU 2004-04-15
  • 打赏
  • 举报
回复
谢谢提醒..:)
chanceqw 2004-04-15
  • 打赏
  • 举报
回复
addr.getHostAddress()
还是addr[i].getHostAddress()???
ShingU 2004-04-15
  • 打赏
  • 举报
回复
public static InetAddress[] getAllByName(String host)
throws UnknownHostException

Returns:
an array of all the IP addresses for a given host name.
chanceqw 2004-04-15
  • 打赏
  • 举报
回复
InetAddress[] addr = InetAddress.getAllByName(name);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
InetAddress.getAllByName()的返回类型是InetAddress
而你的等式左边是个InetAddress数组类型
ShingU 2004-04-15
  • 打赏
  • 举报
回复
没人回答啊...

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧