提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将我的地址设为InetAddress
/* 来自 时 代 J a v a*/ //package com.nowjava; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getMyAddress()); } public static InetAddress getMyAddress() throws UnknownHostException { return InetAddress.getLocalHost(); } }