Control the instance of a class

How can I restrict a class that it can not have more than 5 instances?Please help me to solve this problem.
[121 byte] By [Rakesh_Thawaita] at [2007-11-26 18:09:37]
# 1
http://en.wikipedia.org/wiki/Multiton_pattern
bellyrippera at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 2
Or have a static counter to increase in constructor and make the constructor throw an exception when certain value is exceeded.Mike
bellyrippera at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks Mike.. this is what I was looking for.
Rakesh_Thawaita at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 4
"Multition", eh? I was looking for a word to describe it, but I don't think I've heard that one ever used.
DrLaszloJamfa at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 5
Multiton. I guess its better than Multipleton. =)
duckbilla at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 6
Strange because first time I saw this word was in a discussion here, so I assumed it is widely accepted.Mike
bellyrippera at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...
# 7
Sounds like a cartoon robot villain to me.
DrLaszloJamfa at 2007-7-9 5:41:38 > top of Java-index,Java Essentials,Java Programming...