1 class Tester { 2 public static void checkEqual(String a, String b, String c) {} 3 public static void check(boolean b, String s) {} 4 } 5 6 public class ClassFieldOnPrimitiveTypeLJH 7 { 8 public static void main(String [] args) { test(); } 9 10 public static void test() { 11 Tester.checkEqual(checkBoolean(), "boolean", "boolean"); 12 Tester.checkEqual(checkChar(), "char", "char"); 13 Tester.checkEqual(checkByte(), "byte", "byte"); 14 Tester.checkEqual(checkShort(), "short", "short"); 15 Tester.checkEqual(checkLong(), "long", "long"); 16 Tester.checkEqual(checkFloat(), "float", "float"); 17 Tester.checkEqual(checkDouble(), "double", "double"); 18 Tester.checkEqual(checkIntArray(), "[Z", "boolean[]"); 19 checkIntArray(); 20 } 21 22 public static String checkVoid() { 23 Class c = void.class; 24 return c.getName(); 25 } 26 27 public static String checkBoolean() { 28 Class c = boolean.class; 29 Tester.check(c.isPrimitive(), "check isPrimitive"); 30 return c.getName(); 31 } 32 33 public static String checkChar() { 34 Class c = char.class; 35 return c.getName(); 36 } 37 38 public static String checkByte() { 39 Class c = byte.class; 40 return c.getName(); 41 } 42 43 public static String checkShort() { 44 Class c = short.class; 45 return c.getName(); 46 } 47 48 public static String checkInt() { 49 Class c = int.class; 50 Tester.check( c == Integer.TYPE, "check Type field"); 51 return c.getName(); 52 } 53 54 public static String checkLong() { 55 Class c = long.class; 56 return c.getName(); 57 } 58 59 public static String checkFloat() { 60 Class c = float.class; 61 return c.getName(); 62 } 63 64 public static String checkDouble() { 65 Class c = double.class; 66 return c.getName(); 67 } 68 69 public static String checkIntArray() { 70 Class c = boolean[].class; 71 return c.getName(); 72 } 73 } 74
| Popular Tags
|