它返回的是一个byte[],不是byte,谁告诉你byte[]只能表示-128-127呢

解决方案 »

  1.   

    byte是-128--127
    你的意思是返回的是一个byte数组?那不能这么写吧?add=InetAddress.getAddress()这不是把一个ip地址都付值给了add么?那add具体怎么表示?他输出的时候该怎么写?
      

  2.   

    jdk的帮助已经写得很清楚了
     byte[]      getAddress() 
                  Returns the raw IP address of this InetAddress object他返回的就是一个byte[]
      

  3.   

    如果是ipv4,ip地址是32位的,一般点分为4个10进制的数
    该函数getAddress()每8位用付给一个byteipv6依此类推,byte[]是可变的
      

  4.   

    When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an IPv4 address. When a three part address is specified, the last part is interpreted as a 16-bit quantity and placed in the right most two bytes of the network address. This makes the three part address format convenient for specifying Class B net- work addresses as 128.net.host. When a two part address is supplied, the last part is interpreted as a 24-bit quantity and placed in the right most three bytes of the network address. This makes the two part address format convenient for specifying Class A network addresses as net.host. When only one part is given, the value is stored directly in the network address without any byte rearrangement. For methods that return a textual representation as output value, the first form, i.e. a dotted-quad string, is used. 
      

  5.   

    我觉得不应该老是把ip地址看为10进制数
    对ipv4就是个32位的二进制而已,不就想通了
      

  6.   

    不对,那输出的时候这样写,
    int num=0;
    num=add.Length;
    for(int i=0;i<num;i++)
     System.out.println(add[i]);
    这样下来回什么输出亚?