0
What was the problem here.
The compiler says error on line 1 but if I run this same code on other online compiler it works perfect https://code.sololearn.com/cHlIHHZVUPP7/?ref=app
4 Antworten
+ 5
You can move `enum Size` inside `Test` class, and modify its access level to public.
Then inside Main.main() method, you can refer the enum by specifying the owning class - `Test` - as follows ...
Test t1 = new Test(Test.Size.MEDIUM);
t1.orderPizza();
+ 3
I'm not sure why this works, but if you move enum Size definition after the
class Test definition, the error goes away...
class Test{
...
}
enum Size{
...
}
class Main{
...
}
+ 3
Bob_Li is right.
Usually we would place each class in a separate file. In Sololearn we cannot do that and the mechanism that separates and compiles our single file, is a little wacky. So the order of the classes makes a difference.
+ 2
Thanks Ipang