标题:参数出错
只看楼主
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
结帖率:83.33%
 问题点数:0 回复次数:2 
参数出错
public void actionPerformed(ActionEvent e) {
        try{
            int i=Integer.parseInt(text_input.getText());
            text_hundred.setText(Integer.valueOf(i/100));
//此段有误,提示为setText()参数不能为int型,但上面改成这样也还是不行,到底应该怎么写?

            text_decade.setText(i/10%10);
            text_digit.setText(i%10);
        }
        catch(NumberFormatException nfe){}
        
        
    }

}

[[it] 本帖最后由 yqiong 于 2008-11-12 17:11 编辑 [/it]]
搜索更多相关主题的帖子: 参数 
2008-11-12 17:02
yqiong
Rank: 1
等 级:新手上路
帖 子:315
专家分:0
注 册:2007-7-4
得分:0 
text_hundred.setText(""+(i / 100));
text_decade.setText(""+(i/10 % 10));
text_digit.setText(""+(i % 10));     
为什么改成这样就可以了呀?很纳闷,觉得很奇怪呢!
2008-11-12 17:13
freish
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1223
专家分:437
注 册:2007-6-1
得分:0 
因为用双引号就再加数字就是一个字符串,就是String类型的
2008-11-12 17:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-243838-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.485307 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved