k4h4shi
3/21/2017 - 3:10 PM

AnonymousClass of Java

AnonymousClass of Java

public interface Interface {
	/**
	* this will print out something to console
	*/
	public void print();
}
public class App {
	public static void main(String[] args) {
		// define the class in another expression without a name
		Interface annonymousClass = new Interface() {
			@Override
			public void print() {
				System.out.print("hello world");
			}
		};
		// this method execution will print "hello world" to console.
		annonymousClass.print();
	}
}