在处理J Option Pane时,如何使我的用户输入作为Java中的变量
我是新秀Java编码器,我试图制作一个从用户那里获得价值的程序,我可以在其中分配他/她作为变量进入的任何内容,以便可以通过joptionpane将其显示在框中。 ShowMessageDialog(“”);
如果用户未在框中输入任何内容(这意味着用户输入值等于NULL),则Java必须以的形式响应“您没有输入任何内容” joptionpane.showmessagedialog
。 尽管它一直在说我的一个变量不能“解决”,
但这是错误的位置:
String moviename;
String moviename = JOptionPane.showInputDialog("Whats you favourite movie?");
JOptionPane.showMessageDialog(null, moviename+", sounds like a good watch.");
if (moviename.equals("null")) {
JOptionPane.showMessageDialog(null, "You did not enter anything");
}
I'm a rookie java coder, and I was trying to make a program that receives value from the user in which I can assign whatever he/she enters as a variable so that it can be displayed in a box through JOptionPane.showMessageDialog("");
If the user did not enter anything into the box (Meaning the user input value is equaled to null), java must respond with "You did not enter anything" in the form of JOptionPane.showMessageDialog
.
Although it keeps saying one of my variables cant be "resolved"
here's where the error is:
String moviename;
String moviename = JOptionPane.showInputDialog("Whats you favourite movie?");
JOptionPane.showMessageDialog(null, moviename+", sounds like a good watch.");
if (moviename.equals("null")) {
JOptionPane.showMessageDialog(null, "You did not enter anything");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论