Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Can we declare a static variable inside a method?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
Can we declare a static variable inside a method?
1 Answer(s)      a year and 8 months ago
Posted in : Java Beginners


Hi,

Can we declare a static variable inside a method?

thanks,


Advertisement
View Answers

April 12, 2013 at 10:47 AM


Hi,

The static variable is not attached to a particular object, but rather to the class as a whole. So, the static variable are class level variable and we can't declare inside the method. In case we declare static variable inside the method then it can't compile the program.

For better understanding please visit the link. Hope this will very helpful for you.

http://www.roseindia.net/java/beginners/staticvariable.shtml

Thanks,



Related Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com