class A { static class B { public static void main(String args[]) { System.out.println("hello"); } } } THe above code does not compiles can somebody help. I read some where that u cannot define anything static in Inner class. BUT i am not able to get Y? THe above code Compiles but does not run Y? PLz throe light on this. Thanks in advance sunil.s
"Winners don't do different things<br /> They do things differently"
It does not run because, the main() method is in class B and you are trying to run A!!! It generally helps to look closely at the error message that you get. HTH, Paul. ------------------ Get Certified, Guaranteed! (Now Revised for the new Pattern) www.enthuware.com/jqplus
Hi i modified the code little bit as follows and it compiles and gives the output "hello".
------------------ *********************** Learn from others mistakes. Life is too short to make all the mistakes. ***********************
Sachin,<P>****************************************************<BR>Learn from others mistakes. Life is too short to make all yourself.<BR>****************************************************
THAnks all but i also wanted 2 know why u should not define static in INNER Class . i read somewhere that u cannot define it. y is it so...... ------------------ "Winners don't do different things They do things differently"
"Winners don't do different things<br /> They do things differently"
Hi sachin, I want to know how can you create an object of the static inner class B by using new operator (new() B)? Also how can you call the static method main() in class B by using instance of B ?
Every plan is a little cooler if you have a blimp. And a tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss