I'd like to know how I could fix the illegal start of expression
error on line 3
1 public class Example {
2 public static void main(String[] args) {
3 private int n;
4 }
5 }
Thanks!
Declarations with scope (i.e. private
, protected
, or public
) must be outside your functions, including the main()
one. Move these declarations to the class level to fix this syntax error.
The private
is being used in the body of a method. It can not be used there. It can be used in the body of a class ... outside the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With