• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronized Class

 
faisal usmani
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I have this small question , why cant we have static member functions or variables in a synchronized class .



regards
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no such thing as a synchronized class, so I can't really answer your question. Can you check your words and ask again?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mean to ask "Why can't we have static members in an inner class?" I've wondered about that before...
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff Albertson:
Did you mean to ask "Why can't we have static members in an inner class?" I've wondered about that before...


I'm not sure - but it might be to avoid confusion.

Because an inner class is a non-static member of the outer class, one could wonder whether there a static member of the inner class is "exactly one" or "exactly one per outer class instance".
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:

I'm not sure - but it might be to avoid confusion.

Because an inner class is a non-static member of the outer class, one could wonder whether there a static member of the inner class is "exactly one" or "exactly one per outer class instance".


Obviously it would be the first since static variables belong to the class and there is only one class. I can't think of any reason other than the potential confusion either.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Blair:

Obviously it would be the first since static variables belong to the class and there is only one class.


I wouldn't find it totally off-base to argue that, since the member class isn't static, semantically there should be one class per instance of the outer class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic