Is there any possible way to access the anonymous inner class method? If no why Java compiler allowing to create this method? In java 11

32 views Asked by At
class Vehicle{
    public void park(){
        //Do something
    }
}
class Example{
    public static void main(String args[]){
    Vehicle v1=new Vehicle();
    Vehicle v2=new Vehicle(){
        public void park(){
            //Do something
        }
        public void start(){
            //Do something
        }
        //start();
    }/*.start()*/;
    //v2.start();
    }
}

//All of those calling for start functions are illegal. Is there a possible way to access start function?

0

There are 0 answers