![]() |
| ||
| Well any Java programmer knows that a Java Interface only allows declaration of methods. You cannot define the methods inside interfaces. Yet if somebody like me wants you to define a method in interface and wants the program gets compiled and runs successfully, what would you do? Well the answer is Inner Classes in Java. Through Inner classes, you can define a method in interfaces and run your programs. Here's what you need to do: |
public interface IMain{ public class Main{ public static void main(String [] args){ System.out.println("The main is defined inside an Interface". Don't believe me? Look at the source.. Geee.."); } } } compile the program using javac. run the program by typing java IMain$Main.