I'm trying to compile this program in Netbeans: Lab1.java
And I get this error...
BF.java:27: non-static variable this cannot be referenced from a static context return new Program(new BF().doParse(str));
I've tried everything!
Your Program inner class is not declared static. What this means is that a Program instance can only live inside an enclosing instance of the outer BF class. If you want the Program class to exist independently, so that you can write new BF.Program()
you have to declare it static
.
In your program, you're creating a new instance of Program in the main method in a static context without an enclosing BF instance, which is illegal. Just add static to the program class declaration.