Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>
Multiple markers at this line
- The value of the local variable people is not used
- No enclosing instance of type TestExtends is accessible. Must qualify the allocation with an enclosing instance of type
TestExtends (e.g. x.new A() where x is an instance of TestExtends).
Solution: see if the class is written in another class
For example
public class TestExtends {
public static void main(String[] args) {
human people = new human();
}
class human{
String name;
}
}
The correct writing should be
public class TestExtends {
public static void main(String[] args) {
human people = new human();
}
}
class human{
String name;
}
This is a common mistake when learning object-oriented, hereby record QAQ