+1

Where did I go wrong?

I have a code and I’m trying to figure out what I did wrong flit keep getting an error? https://code.sololearn.com/cYstVzPmc7jx/?ref=app

11/11/2019 8:37:24 PM

amill stacks

3 Answers

New Answer

+4

amill stacks This time only. You have covered enough java course to fix the errors yourself ! public class A { static { vSystem.out.println("1"); int i = 100; } public static void main(String[] args) { //static int i; can't use static here // it should be int i; /* can't use static block here move it outside the main. static { System.out.println("1"); int i = 100; } */ } // <-- this closing bracket was missing } // this is a closing bracket for class public class StaticInitializationBlock { static { System.out.println("2"); } public static void main(String[] args) // ; <-- this semicolon is making main without body { System.out.println("3"); System.out.println("A,i"); } }

+3

You cannot declare a variable explicitly static inside a static function. The sames goes for the static block inside a static function. In first class, main method is missing a closing '}' bracket. In the second class, there is a semicolon at the end of main function, making main without a body.

+1

ok so im new to all this could you show me what you mean