文选流氓 发表于 2003-2-7 01:30

1-1-19-16 请教String、Char[]与Integer的问题

发信人: bloodflower (面条), 信区: Java      
标题: Re: 请教String、Char[]与Integer的问题
发信站: BBS 水木清华站 (Tue May 28 08:39:08 2002)

是不是你自己的char[]数组构造的有问题啊?
我写了一个测试,没有问题啊。


public class test
{
    public static void characters(char[] ch, int start, int length)
    {
      String propValue = new String(ch,start,length); //把字符数组转化为Stri
ng
   
      System.out.println(propValue+"s"+start+"l"+length);
      Integer intValue = new Integer(propValue);
      System.out.println(intValue);
    }

    public static void main(String[] args)
    {
      char[] ch = new char;
      String temp = "12rty";
      temp.getChars(0, 5, ch, 0);
      characters(ch, 0, 2);               
    }
}

【 在 windwe 的大作中提到: 】
:谢谢。
:不过还是一样的错误。不知是不是用char[]构造的String特殊。
: 【 在 Elric (钻石恒久远,一颗永留传) 的大作中提到: 】
: :         int intValue = Integer.parseInt(propValue);
: :         我也忘的差不多了,你自己试试吧
页: [1]
查看完整版本: 1-1-19-16 请教String、Char[]与Integer的问题