我有一小段代码可以编译,并允许用户在终端窗口中输入图形(我正在使用Blue J)。
但是,尽管它可以“编译”,但我永远无法打开,查看或与终端窗口进行交互。我遇到一个红色的“对象框”。
我已经尝试了一段时间来解决此问题,但似乎无法在任何地方找到答案。
这是使用的代码:
import java.util.Scanner;
public class PartA
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Input your message: "); //this is the user promot
String message = input.nextLine();
System.out.println(message);
}
}
最佳答案
自发布以来,我已经找到了解决此问题的方法。
当我单击新的PartA()在终端窗口中查看程序时,这仅创建了一个对象(红色框)。通过单击public static void main(String [] args)(本质上是一种与对象相对的方法),我可以查看终端窗口并与之交互。
关于input - BlueJ用户输入代码永远不会编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11597773/