import java.io.*; public class Test { public static void main(String args[]) { Integer b1 = new Integer("427"); System.out.println("変数"); System.out.println(" MAX_VALUE " + Integer.MAX_VALUE); System.out.println(" MIN_VALUE " + Integer.MIN_VALUE); System.out.println("数値へ変換"); double d = b1.doubleValue(); // d = (double)b1は許されない int i = b1.intValue(); System.out.println(" Integer " + b1 + " double " + d + " int " + i); System.out.println("int型へ変換"); System.out.println(" 文字列 427 を変換 " + Integer.parseInt("427")); System.out.println(" 文字列 1AB を変換 " + Integer.parseInt("1ab", 16)); System.out.println("文字列へ変換"); System.out.println(" 427 を2進文字列へ変換 " + Integer.toBinaryString(427)); System.out.println(" 427 を8進文字列へ変換 " + Integer.toOctalString(427)); System.out.println(" 427 を16進文字列へ変換 " + Integer.toHexString(427)); System.out.println(" " + b1 + " を文字列へ変換 " + b1.toString()); System.out.println(" 427 を文字列へ変換 " + b1.toString(427)); System.out.println(" 427 を16進文字列へ変換 " + b1.toString(427, 16)); System.out.println("Integerへ変換"); System.out.println(" 文字列 427 を変換 " + Integer.valueOf("427")); System.out.println(" 文字列 1AB を変換 " + Integer.valueOf("1ab", 16)); } }
変数 MAX_VALUE 2147483647 MIN_VALUE -2147483648 数値へ変換 Integer 427 double 427.0 int 427 int型へ変換 文字列 427 を変換 427 文字列 1AB を変換 427 文字列へ変換 427 を2進文字列へ変換 110101011 427 を8進文字列へ変換 653 427 を16進文字列へ変換 1ab 427 を文字列へ変換 427 427 を文字列へ変換 427 427 を16進文字列へ変換 1ab Integerへ変換 文字列 427 を変換 427 文字列 1AB を変換 427