Since methods inside an interface cannot have a body, you will not be able to declare innerclasses within methods inside the interface. Top level classes are permitted and legal. Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Aftab, The best tool to learn Java is the Java compiler itself( javac.exe ). Whenever you don't understand a concept, write code and play with it. Nothing helps you more than hands-on learning experience. Having said that, why don't you try to compile the following program and see what happens.
Good luck, Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Hi Aijth, thanx help me and give example code also. but your last code dosn't complie and give following error which given belown. Outer.java:5: Member interfaces can only occur in interfaces and op-level classes. interface IFaceInInnerClassScope ^ Outer.java:10: Member interfaces can only occur in interfaces and top-level classes. IFaceInLocalInnerClassScope ^ 2 errors hope u tell me about this thanx Aftab
Hi Aftab, You posted an interresting topic. Now to your question. As you may be knowing there are four types of nested classes/interfaces possible in Java. *) Top-level nested class/interface. *) Non-static class. *) Local class. *) Anonymous class. The top-level classes are the static classes defined inside another class. All the nested interfaces are by default static . meaning there's no thing like non-static interface or local interface defined inside a method. So the compiler says just that. Refer Khalid for more information.
------------------ Regards --------- vadiraj
***************** There's a lot of I in J. *****************
Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************