int i = Integer.parseInt(your-integer).intValue()这样出来的就是没有0的了

解决方案 »

  1.   

    我的目的是写一个方法,参数是全是数字的字符串,可能有小数点,只要去掉前面的0,并返回前面没有0的字符串。int 无法满足要求
      

  2.   

    可以把Integer换成Double呀!public class TestDouble {    public static void main(String[] args) {
            String s = "00001000.11";
            double d = Double.parseDouble(s);
            System.out.println(d);
        }
    }
      

  3.   

    public class cnfree{    String str="00032443";
        String str1="";
        public cnfree(){
                    for(int i=0;i<str.length();i++)
                      {
                        char c=str.charAt(i);
                        if(c!='0'){
                          str1+=str.substring(i);
                          System.out.println(str1);
                          break;
                        }           }
        }
            public static void main(String[] args) {
                            cnfree sdf=new cnfree();
            }
    }
      

  4.   

    chensuper 的答案不符合要求
      

  5.   

    既然参数是数字,使用Integer.parseInt(String),然后再Integer.toString(int)不就行了吗。
      

  6.   

    呵呵
    我想既然是字符串,那么长度就不会有限制
    所以楼上的方法
    “Integer.parseInt(String),然后再Integer.toString(int)”
    不见得满足
    其实自己写一个方法也不麻烦哦!^_^
      

  7.   

    看看这个可以不?/**
    * change.java
    */public class Change {
        public static void main( String[] args ) {
            String str = "00001001.23542";
            String s = convert( str );
            System.out.println( s );
        }

        static String convert( String a ) {
            int len = a.length();                          //取长度
            String b = "";
            int i = 1, j = 1;
            while( a.charAt(i) == '0' && i < len  ) i ++;  //找到第一个不是0的位置
            if ( i < len ) {
                b = a.substring( i, len );                 //拷贝
            }
            return b;
       }
    }
      

  8.   

    chongchong2001(虫虫) 的应该可以了。
    要不先去一下两头的空格吧!呵呵
      

  9.   

    如果用double,出来的数字默认是科学记数法,字符串都变了。只能自己写方法来实现。虫虫的方法对字符串前面有不可见字符不能处理。不过这种情况应该比较少把。
      

  10.   

    不过既然说了是全是数字的字符串,就可以忽略掉不可见字符
    勉强还可以!
    不过说回来
    teaky2002(种田硬手) 所书说的思路
    那就从第一个'1'--'9'的字符开始
    顺便问一声
    不可见字符都有哪些
    后者说范围呢?