class example { public static void main(String args[]) { static int h = 8; System.out.println(h); } } When I compile this program, it gives an comilation error: Statement expected : static int h = 8; Identifier expected: System.out.println(h); Can anyone please explain this? Thankx Shilpa Jain
Hi Shilpa, You cannot assign the static modifier and access permissions like private, protected, public etc. to variables within a local method. These are applicable only to class variables. If you want to print h which is defined within the static method main(), you need not declare h as static. A simple 'int h =0;' will do. Regds Sathish
Hi Satish, Thanks for the reply.. You seem to be having all Java basics and fundamentals on your finger tips man.. Can you suggest some books and advices so that i too can become confident and good in Java Cheers Venu
Hang a left on main. Then read this tiny ad:
Gift giving made easy with the permaculture playing cards