object类型的数据是一个对象怎么能和int比较呢

解决方案 »

  1.   

    试试Integer.parseInt(String(xxx));
    注意要捕获NumberFormatException异常.
      

  2.   

    或者试试Integer.parseInt(xxx.toString());
      

  3.   

    String tempStr ;
        tempStr = "123";
        try{
          Integer.parseInt(tempStr);
          System.out.println("int");    }catch(Exception ex) {
          System.out.println("not int");
        }
      

  4.   

    同意iforem的说法。
    int是一个primitive type,Object是一个对象,无法比较,但可以判断是否是Integer.
      

  5.   

    我就是要判断一下那个object是不是int型的数据.
    不是为了比较哦.因为在参数传递的时候可能是string类型的object或者是int型的object
    如何操作呢?
      

  6.   

    int是一个primitive type,Object是一个对象,无法比较,但可以判断是否是Integer.同意
      

  7.   

    int是一个primitive type,Object是一个对象,无法比较,但可以判断是否是Integer.同意
    光说这个有什么用啊,要解决的方法啊,,怎么判断啊?
      

  8.   

    public class Test {
     
    public static void main(String[] args){
    Object o=new String("df");
    try{
    Integer theInt=(Integer)o;
    System.out.println(theInt);
         }catch(ClassCastException e){
         System.out.println("the object doesn't contain a int");
         }
        


    }
      

  9.   

    我猜仁兄的问题大概是从哈希表之类的地方取到一个Object,但要验证是不是一个数字组成的字符串!
    Object aValue=userInf.getObject("msisdn");测试Pattern.matches("\\d+",(String)aValue)就是你的答案!
      

  10.   

    http://community.csdn.net/Expert/topic/3724/3724891.xml?temp=.4873011
    具体要解决的问题是这个 啊.没办法了,只好这么解决了,但是无法判断哦
      

  11.   

    try一下,
    然后在异常中处理就行了
    如果不是,
    就会跳到异常中去的