日期:2014-05-20  浏览次数:20699 次

请问如何判断基本数据类型
请问如何判断基本数据类型
比如我有一个变量   int   i   =   1;
我怎么判断i是属于int型的呢

------解决方案--------------------
class TestType{
public static String typeOf(boolean i){
return "boolean ";
}
public static String typeOf(byte b){
return "byte ";
}
public static String typeOf(short s){
return "short ";
}
public static String typeOf(char c){
return "char ";
}
public static String typeOf(int i){
return "int ";
}
public static String typeOf(float f){
return "float ";
}
public static String typeOf(long l){
return "long ";
}
public static String typeOf(double d){
return "double ";
}
public static void main(String[] args) throws Exception{
int i = 10;
System.out.println(typeOf(i));
}
}
不知道这样能不能满足要求?