I have a small piece of code that should compile and allow the user to input a figure in the terminal window ( I am using Blue J).
However, while it does ‘compile’, I can never open, view or interact with the terminal window. I am met with a red “object box” instead.
I have been trying for a while to get around this problem and I can’t seem to find the answer anywhere.
Here is the code used:
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);
}
}
I’ve figured out the answer to this problem since posting.
While I was clicking on new PartA() to view the program in the terminal window, this only created an object (the red box). By clicking on public static void main(String[] args) (essentially a method as opposed to an object) I was able to view, and interact with the terminal window.