在处理J Option Pane时,如何使我的用户输入作为Java中的变量

发布于 2025-02-11 05:07:48 字数 596 浏览 1 评论 0原文

我是新秀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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文