Posts

Showing posts with the label Collection framework

List interface in java with examples

Read this article to know what is List interface and what are the List implemented classes in java with example programs.  List interface  represents a group of elements arranged like an array in java. List will grow dynamically when the elements are stored into it. List will allow duplicate elements to store into it. List interface implemented classes are,   ArrayList<E> Vector< E > LinkedList< E >           < E > represents the genetic type of storing element into List. List interface methods: The below are the list of methods which are available in List Interface. These methods are also available in subclasses of the List interface.   void add( int position, element obj): Adds the second argument into the List at the index specified by the first argument.   void add(element obj): This method appends the specified element to the end of the ArrayList. If the element is added successfully then the preceding meth

collection framework in java with example

Image
Collection framework is a class library to handle group of objects. Collection framework implemented in java.util package. A collection object or container object is an object which can store a group of other objects. A collection object has a class called ' Collection class ' or ' Container class '. All the collections classes are available in the package java.util (util stands for utility). A group of collection classes are called a ' Collection Framework '. The above diagram represents the hierarchy of Collection Framework and the list of available interfaces with their implementation classes. How can we handle a group of elements? We use an array to store a group of elements and handle them easily. How can we handle a group of objects? How can we use an array to store a group of objects? Yes, it is possible to use an array to store a group of objects. Using an array to store a group of objects:

Collection Framework interview questions and answers in java

In this current page we will come to know about collection framework interview questions with answers. It may possible to ask questions out of these questions. But, these questions and answers will definitely helps you to answer easily collection framework questions. If any of you are facing more then these interview questions please share with me through "Contact me here" gadget or drop me an email to " admin@javatbrains.com ".     1. What is a Collection Framework? A: A Collection framework is a class library to handle groups of objects. Collection framework is implemented in java.util package. 2. Does a collection object store copies of other objects or their references? A: A Collection object stores references of other objects. 3. What are the major interfaces in java.util package? A: List: A List represents a group of elements arranged just  like an array. A List will grow dynamically when the elements are stored into it. List stores a group of elemen