anonymous inner class in Java

An anonymous inner class is a local inner class that does not have a name. It is declared and instantiated all in one statement using the new keyword. Anonymous inner classes are required to extend an existing class or implement an existing interface. They are useful when you have a short implementation that will not be used anywhere else. 
* No access specifier. Already local to method.
* Can not extend any class and implement any number of interfaces. Must have exactly one superclass or one interface.
* Can not be abstract because no class definition
* Can not be final because no class definition
* Can access instance members of enclosing class including private members
* Can not access local variables of a method unless those variables are  final or effectively final.  The compiler is generating a class file from your inner class. A separate class has no way to refer to local variables. If the local variable is  final , Java can handle it by passing it to the constructor of the inner class or by storing it in the class file. If it weren’t effectively final, these tricks wouldn’t work because the value could change after the copy was made. Up until Java 7, the programmer actually had to type the  final keyword. In Java 8, the “effectively final” concept was introduced. If the code could still compile with the keyword  final  inserted before the local variable, the variable is effectively final.    
* Can not be declared  static  and cannot declare  static  fields or methods.  

```
public class Main {
    abstract class SaleTodayOnly {
        abstract int dollarsOff();
    }

    public int admission(int basePrice) {
        SaleTodayOnly sale = new SaleTodayOnly() {
            int dollarsOff() {
                return 3;
            }
        };
        return basePrice - sale.dollarsOff();
    }
}
```