why it's wrong

adot111 2003-10-21 11:14:31
import javax.swing.*;
public class A{
public static void main(String agrs[]){

String input;

//String newinput = " ";

boolean yes = true;

while(yes){
input = JOptionPane.showInputDialog("Enter a word, please");

for(int i = 0; i<input.length(); i++)
{
if("AEIOUaeiou".indexOf(input.charAt(i)) > -1)
input = input.substring(0,i) + "*" +input.substring(i+1);
}

System.out.println(input);

String choose = JOptionPane.showInputDialog("You wanna play again, 1 or 2");

char y;

if(choose.equals(""+y))

yes=false;


}
}
}

why it tells me that

H:\A.java:26: variable y might not have been initialized
if(choose.equals(""+y))
^
1 error

Tool completed with exit code 1
...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ldh_0421 2003-10-21
  • 打赏
  • 举报
回复
同意楼上观点!
fft123 2003-10-21
  • 打赏
  • 举报
回复
char y;
定义的y没有初始化就拿来用了
给个初值再用

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧