Hi, I am not sure in what context u read these container, If you are aware of Vectors, here a Vector can act as a container and can store objects of any type. In general example suppose you want to store an Object of type String and one array object of integer, In a vector you can add both and then again u can takeout to use this. you can refer to any java book for details. thanks Anurag
There are several different kinds of containers (usually called "Collections" in Java.) Of course they all have in common that they maintain a group of objects, so one useful scenario is just that: a video game program might need a list of Monsters. You could use an array, but a collection like ArrayList or LinkedList makes it easy to add and delete items from the collection (as Monsters are killed or hatched) without worrying about the changing the size of the array. Other collections have more specialized uses. A Set lets you hold a collection of items but automatically removes duplicates. By iterating over the words in a document and adding each one (as a String) to a Set, you get a collection of the unique words in the document. If it's a SortedSet, then you automatically get that collection in sorted order. A Map is a very useful collection that lets you look up things quickly given a key. If an application included a few thousand Person objects (a personnel application, perhaps) then you might store those Person objects in a Map using their name as the key; then you can very quickly look up a Person by name. Collections have a million and one uses, in Java and in any language.
hi, A container is a component which can contain other components inside itself. It is also an instance of a subclass of java.awt.Container. java.awt.Container extends java.awt.Component so containers are themselves components. In general components are contained in a container. An applet is one container. Other containers include windows, frames, dialogs, and panels. Containers may contain other Containers. Every container has a LayoutManager that determines how different components are positioned within the container. In short containers contain components. Components are positioned inside the Container according to a LayoutManager. Since containers are themselves components, containers may by placed inside other containers. This is really a lot simpler than it sounds. Applets provide a ready-made container and a default LayoutManager, a FlowLayout. bhramaresh
Ah, great things going on here! Be aware we are talking about two very different kinds of containers. It's bad to overload English words! Smalltalk people called their Collection things "containers" and the term still hangs on. If you start with the Collection interface and look at some of the implementations you'll find lots of good ways to stash a bunch of objects away until you need them later. I vote we try to call these Collections and not containers. Java AWT and Swing folks have their own concept of containers, and those are UI widgets that can contain other UI widgets. Frames can contain panels, panels can contain buttons, panels can contain panels, on and on forever. That's where we use layout managers to influence (I can't quite say control) visual layouts. Now, can we get Landon back online to clarify which kind he was asking about?
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi