+ 3
Can anyone please explain me any situation where these anonymous classes are useful??
1 Antwort
+ 1
If you are talking about Java, it is (was) commonly used to subclass `Runnable` or similar. For example maybe you have a "runInAnHour" function that runs a piece of code in an hour. Then you can
runInAnHour(new Runnable(){
void run(){
// this runs in an hour
}
});