您现在的位置是:首页 > 产经 >正文

今日for input string:是什么原因出现的(forinputstring)

发布时间:2022-07-11 00:12:43伏爱飘来源:

导读 大家好,小良来为大家解答以上问题。for input string:是什么原因出现的,forinputstring很多人还不知道,现在让我们一起来看看吧!1、解...

大家好,小良来为大家解答以上问题。for input string:是什么原因出现的,forinputstring很多人还不知道,现在让我们一起来看看吧!

1、解析的字符为""就会导致如上异常,String[]tokens=str。拆分(');是否应改为string[]tokens=str。拆分(“”);若是要将输入按照一个一个字符拆分使用字符串字符(索引)

2、修改后的代码如下,不知道是不是符合你原意

3、导入javax。挥棒。joptionpane

4、公共类测试{

5、公共静态void main(String[] args) {

6、(同Internationalorganizations)国际组织奇数=0,偶数=0,零=0,x;

7、string str=JOptionPane。showinputdialog(null,'请输入一个数字,'输入',JOptionPane .信息_消息);

8、for(int I=0;IX=整数。parse int(str。charat(I)“”);如果(x==0)零;else if(x%2!=0)奇数;否则就算了;} String s=' prints :s=str ' \ n ' ' odd : '奇数\n' 'Even: '偶数\n' 'Zero: '零;JOptionPane。showmessagedialog(null,s,' Keyboard ',JOptionPane .信息_消息);} }

本文到此结束,希望对大家有所帮助。

标签:

上一篇
下一篇

最新文章