aspose file tools*
The moose likes Beginning Java and the fly likes Synchronized Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Synchronized Class " Watch "Synchronized Class " New topic
Author

Synchronized Class

faisal usmani
Ranch Hand

Joined: Jan 14, 2006
Posts: 139
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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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?


[Jess in Action][AskingGoodQuestions]
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Did you mean to ask "Why can't we have static members in an inner class?" I've wondered about that before...


There is no emoticon for what I am feeling!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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".


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
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

Joined: Jul 11, 2001
Posts: 14112
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized Class