Hi, The reason is local variable cannot be declared static. thanks, vinu.
RAMA KRISHNA AALLA
Greenhorn
Joined: Aug 10, 2005
Posts: 29
posted
0
I think,
"Static methods can't have static variables or static blocks inside them"
Plz Correct me if i am wrong!
Cheers, Rama Krishna Chowdary
Santana Iyer
Ranch Hand
Joined: Jun 13, 2005
Posts: 335
posted
0
Simple reason as mentioned above, main is a method and so can not have static modifier for variable, only modifier allowed in method is final,
final int x=19;
hope this helps, correct me if required.
Jyothi Bhogadi
Ranch Hand
Joined: Jul 08, 2005
Posts: 47
posted
0
hello Ramakrishna, not only static methods... but i guess none of the method variables can have static as their modifier.....and only final is allowed and nothing else for a method variable.
Some body please correct me if i am wrong.
Regards Sam
shashikanth penumadula
Ranch Hand
Joined: May 26, 2005
Posts: 32
posted
0
hi a local variable can have only a variable type and identifier. it cannot have keywords like public , private, protected, final, static , transient or volatile.
static var i in main is not shadowing the class level variable i declared. static modifier for variables cannot be used insie methods, its a compile time error.
Your's Aakash
SCJP 1.4 96%, SCBCD 1.3 94%
Smitha Ballikar
Ranch Hand
Joined: Aug 02, 2005
Posts: 99
posted
0
Hi, Thanks!!
Shivani Chandna
Ranch Hand
Joined: Sep 18, 2004
Posts: 380
posted
0
Originally posted by shashikanth penumadula: hi a local variable can have only a variable type and identifier. it cannot have keywords like public , private, protected, final, static , transient or volatile.
variables can have final as modifier in local scope.
/** Code speaks louder than words */
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
posted
0
err... u cant have local static varaibles. thats it
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)