Edward Torres Edward Torres - 2 months ago 9
Java Question

'{' expected error. what is missing

I have no idea why this error is occurring

both of the { are closed properly?

public class Display 1_1
{
public static void main(String[] args)
{
System.out.println("Hello reader.");
System.out.println("Welcom to java.");

System.out.println("Let's demonstrate a simple calculation.");
int answer;
answer = 2 + 2;
System.out.println("2 plus 2 is " + answer);
}


}

Answer

The 1_1 after Display is a syntax error. You should either remove it or make it part of the name of the class by removing the space between it and Display.