⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inetaddresstest.java

📁 kaffe Java 解释器语言,源码,Java的子集系统,开放源代码
💻 JAVA
字号:
import java.net.InetAddress;import java.net.Inet6Address;public class InetAddressTest{    public static void main(String args[])	throws Throwable    {	InetAddress ia;	ia = InetAddress.getByName(null);	System.out.println("(null) = " + check(ia));		ia = InetAddress.getByName("");	System.out.println("\"\" = " + check(ia));	ia = InetAddress.getByName("localhost");	System.out.println("localhost = " + check(ia));	if( !ia.isLoopbackAddress() )	{	    System.out.println("Not a loopback?");	}    }    private static String check(InetAddress ia)         throws Throwable    {        String expected = (            ia instanceof Inet6Address ?                "localhost/::::::::1" :	        "localhost/127.0.0.1" );        if (ia.toString().equals(expected)) return "localhost/127.0.0.1";        return ia.toString();    }}/* Expected Output:(null) = localhost/127.0.0.1"" = localhost/127.0.0.1localhost = localhost/127.0.0.1*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -