Programming in Java
Object Oriented in Java
Advanced topics in Java
Modal Box
Tutorials
C is a very powerful and widely used language. It is used in many scientific programming situations. It forms (or is the basis for) the core of the modern languages Java and C++. It allows you access to the bare bones of your computer.C++ is used for operating systems, games, embedded software, autonomous cars and medical technology, as well as many other applications. Don't forget to visit this section...
Collection in Java
In java, a collection is the group of objects which provide readymade architecture to manipulate them.
In java some important collection classes and interfaces are as following :
a. ArrayList
b. LinkedList
c. Vector
d. List
e. HashSet
f. HashMap
g. TreeSet
h. TreeMap etc.
To use collection, java.util package needs to be imported.
Advantage of collection over array is to provide dynamic memory allocations.
ArrayList in java :
Exmaple to show implementation of ArrayList.
class ArrayListDemo { public static void main(String args[]) { ArrayList list= new ArrayList();// Default Type array List is created. list.add("delhi"); // elements are added to the arraylist list.add("fbd"); list.add("noida");
//loop to display elements in array list for(int i=0;i<list.size();i++) { System.out.println(list.get(0)); } } }
Similarly, we can create arrayList of other type such as string type etc.
ArrayList<String> list = new ArrayList<String>();
Vector :
Implementation of Vector is shown below.
class VectorDemo { public static void main(String args[]) { Vector v = new Vector(); v.addElement("Java"); v.addElement("C++"); v.addElement("Python");
for(int i=0; i<v.size();i++) { System.out.println("Item:"+v.get(i)); } } }
Video/ C Introduction
Watch video in full size