aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static" Watch "static" New topic
Author

static

Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
vinuharan haran
Ranch Hand

Joined: Feb 26, 2005
Posts: 64
Hi,
The reason is local variable cannot be declared static.
thanks,
vinu.
RAMA KRISHNA AALLA
Greenhorn

Joined: Aug 10, 2005
Posts: 29
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
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
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
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.
Aakash Parashar
Ranch Hand

Joined: Jul 25, 2005
Posts: 122

Smita,

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%, http://java-application-programming.blogspot.in
Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
Hi,
Thanks!!
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
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
err... u cant have local static varaibles. thats it


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static