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

解决方案 »

  1.   

    基础类型好像不能判断
    Integer i=0;
    System.out.println(i.getClass());
    class java.lang.Integer
      

  2.   

    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));   
        }   
      }
    不知道这样能不能满足要求?
      

  3.   

    firefox_1983(上班-吃饭-下班-吃饭-上网-睡觉?)想法挺好的。