import java.net.*;
import java.io.*;
public class IPVersion {
public static void main(String args[]) {
try {
InetAddress inetadd = InetAddress.getLocalHost();
byte[] address = inetadd.getAddress();
System.out.println(address);
if (address.length == 4) {
System.out.println("The ip version is ipv4");
int firstbyte = address[0];
if (firstbyte < 0)
firstbyte += 256;
if ((firstbyte & 0x80) == 0)
System.out.println("the ip class is A");
else if ((firstbyte & 0xC0) == 0x80)
System.out.println("The ip class is B");
else if ((firstbyte & 0xE0) == 0xC0)
System.out.println("The ip class is C");
else if ((firstbyte & 0xF0) == 0xE0)
System.out.println("The ip class is D");
else if ((firstbyte & 0xF8) == 0xF0)
System.out.println("The ip class is E");
} else if (address.length == 16)
System.out.println("The ip version is ipv6");
} catch (Exception e) {
}
;
}
}