aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collection Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collection Objects" Watch "Collection Objects" New topic

Collection Objects

Harini Mamidi

Joined: Jan 05, 2004
Posts: 11
Are the collection objects immutable? like for example java.util.Vector...?
[ January 09, 2004: Message edited by: Harini Mamidi ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Of course not. Notice that the collection objects have methods such as add and remove. These directly imply that the collections can be changed and, therefore, are not immutable.
Saying that something is immutable means simply that it CAN NOT be changed after it is created. That is certainly not the case with a collection.

SCJP Tipline, etc.
Harini Mamidi

Joined: Jan 05, 2004
Posts: 11
Thank U for the reply
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
You CAN create immutable collections. The easiest way is by using the class java.util.Collections. There are several static methods (the methods' names start with 'unmodifiable'). The harder way is to create your own class that implements Collection interface or to extend the existing collection classes.
I agree. Here's the link:
subject: Collection Objects