怎么可能老是出错?

huangran_lw 2001-11-02 12:45:38
这是我写一个程序,看看哪里出错了,我总是找不出错误。thxpackage net;
import java.net.*;
public class IPAddressSeek
{
public IPAddressSeek()
{
super();
}
public static void main(String[] args)
{
InetAddress hostAddress;
byte[] integer_address;
if (args.length==0)
{
try
{
hostAddress=InetAddress.getLocalHost();
integer_address=hostAddress.getAddress();
System.out.println("The domain name of localhost is:\n\t\t\t"+hostAddress.getHostname());
System.out.println("The IPAddress of localHost in the form of standardDot is:\n\t\t\t"+hostAddress.getHostAddress());
System.out.println("The IPaddress of localhost in the form of 4_integer_byte is:\n\t\t\t"+integer_address[0]+"\t"+integer_address[1]+"\t"+integer_address[2]+"\t"+integer_address[3]);
}catch(UnknowHostException e)
{e.printStackTrace();}
}else
{
try
{
hostAddress=InetAddress.getByName(args[0]);
integer_address=hostAddress.getAddress();
System.out.println("The domain name of localhost is:\n\t\t\t"+hostAddress.getHostname());
System.out.println("The IPAddress of localHost in the form of standardDot is:\n\t\t\t"+hostAddress.getHostAddress());
System.out.println("The IPaddress of localhost in the form of 4_integer_byte is:\n\t\t\t"+ integer_address[0]+"\t"+integer_address[1]+"\t"+ integer_address[2]+"\t"+integer_address[3]);
}catch(UnknowHostException e)
{e.printStackTrace();}

}
}
}
...全文
33 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangran_lw 2001-11-02
  • 打赏
  • 举报
回复
thank u.
我确实看了很久,但是我看一出来。我是初学者.
karma 2001-11-02
  • 打赏
  • 举报
回复
God, you are lazy,

change "UnknowHostException" to "UnknownHostException"
change "getHostname" to "getHostName"

62,615

社区成员

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

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