import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
public class ylh1 {
public static void main(String[] args) throws UnknownHostException {
InetAddress inetAddress=InetAddress.getByName("MM-202207081226");
String hostAddress = inetAddress.getHostAddress();
System.out.println("主机的ip地址是:"+hostAddress);
String hostName = inetAddress.getHostName();
System.out.println("主机的名称是:"+hostName);
}
}
主机名称在设置中查看