Non static object in main

Main.java:13: error: non-static variable this cannot be referenced from a static context
BST b=new BST(arra);

IN THE VIDEO LECTURES WE WERE TAUGHT TO CREATE ANOTHER FILE FOR OUR CLASSES AND WE USED TO RUN OUR CLIENT MAIN CLASS IN ANOTHER FILE, SO HERE, HOW WE ARE SUPPOSED TO DO ?

Doesn’t really matter, classes can be kept in a single file as well as multiple files for each class. But it’s advisable for you to keep the classes with their independent functionality into separate files. As for the error, you are accessing a non - static variable or an instance variable from a static method which isn’t possible in Java. For the workout, you could create an object of the same class within the static method and then use that object to access that instance variable. Or another way to deal with this is to, create another instance method and make a call to the static method from this method passing the instance variable as a parameter now to the static method. Now, since this variable becomes a local variable for the static method, it can easily access the value.

well, i opened the editorial solution and tried running it

Main.java:2: error: class BST is public, should be declared in a file named BST.java public class BST { ^ 1 error

an error came as shoen above, and the same error came with my code too. but now i cannot submit since i opened the solution. however please tell that why still an error is coming

just remove public from the class name and try submitting it