Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can a top level class be private ?

 
Rekha Suri
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can a top level class be declared private or protected ? This is from the Round Up game in this site. Any clarification will be helpful.
Thanks.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making one, and see what the compiler will let you.
 
Nilesh Parikh
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
the only access modifier that can go with the top level class is public. you can not make the top level class private or protected
ALkesh
 
Nalini Mistry
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private and protected cannot be used with classes
 
Javix Protocol
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey u can use the keywords in methods and variables for the purpose of encapsulation and managing abstraction through that.
But giving the same to a class name suggests that u are reducing ur portability .See whether u can make the keywords in innerclass
since their they might be useful for the encapsulation of class members.Adieu..
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, private and protected may be used as access modifiers for inner or nested classes. Marcus Green's tutorial has been updated to reflect this fact.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic