i was trying to create an anon class in java
class myClass {
int x = 10;
}
public class Main {
public static void main(String[] args) {
myClass myObject = new myClass() {
public void run(){
System.out.println(x);
}
};
myObject.run(); //gives an error saying "method run() is undefined for the type myClass"
}
}
and it does not seem to work at all , it gives me an error saying that method run() is undefined although i created an anon class containing the run() mehtod , i am a complete java beginner , i code most of the time in javascript , javascript is the language i am most familiar with and i am trying to get used to java concepts so yeah this question might seem silly to alot of people here and i apologize for that. thanks in advance