发布网友 发布时间:2022-04-24 18:41
共1个回答
热心网友 时间:2022-05-19 14:46
import <a href="https://www.baidu.com/s?wd=java.net&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1d9mHwhPyfvuAD1Phu-PjRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3En1c3nW6vPWDz" target="_blank" class="-highlight">java.net</a>.*;
public class Test6 {
public static void main(String[] args) {
// TODO Auto-generated method stub
InetAddress ia=null;
try {
ia=ia.getLocalHost();
String localname=ia.getHostName();
String localip=ia.getHostAddress();
System.out.println("本机名称是:"+ localname);
System.out.println("本机的ip是 :"+localip);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}