• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

static&protected

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A static variable is available to the entire class.
A protected variable is available to the classes in the same package and sub classes in other packages.

what happenes if the variable is both static and protected?
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by muralik krishnam:
A static variable is available to the entire class.



"static" has nothing to do with access control.

A static field or method is used without reference to an instance of the class. A non-static field or method can only be used through a reference to an instance of the class.

"protected" is an access modifier.

So "static" and "protected" are totally different and asking the difference between them is like asking the difference between "fast" and "blue".
 
reply
    Bookmark Topic Watch Topic
  • New Topic