Skip to content
Advertisement

Why this Java code is showing identifier expected error? [closed]

I am learning Java and came across this problem. The problem statement is not much important here. While running the code I am getting an error. The code is

JavaScript

And the error is

JavaScript

I have searched many online sources to fix the error but unable to find it. Can someone help what is the reason for that error?

Advertisement

Answer

public is a keyword and case matters.

You wrote Public which the compiler didn’t understand as a keyword but thought you might be referencing a type called Public and thus is waiting for a variable name (thus “identifier expected”).

Change Public to public.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement