marq

Dr. Charles Simonyi is the Father of Modern Microsoft Excel                                           JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, later LiveScript, and finally renamed to JavaScript.                                           The word "Biology" is firstly used by Lamarck and Treviranus                                           Hippocrates (460-370 bc) is known as father of medicine.                                           Galene, 130-200 is known as father of Experimental Physology                                           Aristotle (384-322 BC) is known as Father of Zoology because he wrote the construction and behavior of different animals in his book "Historia animalium"                                           Theophrastus(370-285 BC) is known as father of Botany because he wrote about 500 different plants in his book "Historia Plantarum".                                           John Resig is known as Father of Jquery -                                          HTML is a markup language which is use to design web pages. It was invented in 1990 by Tim Berners-Lee.                                                                The Google was founded by Larry Page and Sergey Brin.                                                                Rasmus Lerdorf was the original creator of PHP. It was first released in 1995.                                                               Facebook was founded by Mark Zuckerberg                                                               Bjarne Stroustrup, creator of C++.                                                                Dennis Ritchie creator of C                                                                                                                              James Gosling, also known as the "Father of Java"                                          At 11.44%, Bihar is India's fastest growing state                                          Father of HTML -Tim Berners Lee                                          orkut was created by Orkut Büyükkökten, a Turkish software engineer                    Photoshop: It came about after Thomas Knoll, a PhD student at the University of Michigan created a program to display grayscale images on a monochrome monitor which at the time was called 'Display'.

vector


The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of aVector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.
Each vector tries to optimize storage management by maintaining a capacity and a capacityIncrement. The capacity is always at least as large as the vector size; it is usually larger because as components are added to the vector, the vector's storage increases in chunks the size of capacityIncrement. An application can increase the capacity of a vector before inserting a large number of components; this reduces the amount of incremental reallocation.
As of the Java 2 platform v1.2, this class has been retrofitted to implement List, so that it becomes a part of Java's collection framework. Unlike the new collection implementations, Vector is synchronized.




import java.util.*;
class co
{
     public static void main(String arg[])
     {
         Vector v=new Vector();
         v.addElement("a");
         for(int i=0;i<10;i++)
         {
        v.addElement(new Integer(i));
         }
         System.out.println(v);
         System.out.println(v.capacity()); // 10
         v.add("b");
         System.out.println(v.capacity()); // 20
    }
}

******************************************************************



import java.util.*;

class co1
{
 public static void main(String[] args)
 {

     ArrayList a1=new ArrayList();
 
         a1.add(new Integer(10));
         a1.add("hello");
         a1.add(new Integer(20*5));
         a1.add(new Integer(30));

     System.out.println(a1);  // here ArryList toString method called

     // By using  iterator
 
     Iterator i1=a1.iterator();

     while(i1.hasNext())
             System.out.println(i1.next());
          

         }
}


*****************************************************************************

 import java.util.ArrayList; 
public class co2 
{  public static void main(String[] args)
 {  
  //create an ArrayList object  
 ArrayList arrayList = new ArrayList();
//Add elements to Arraylist    

arrayList.add("1");
arrayList.add("2");
arrayList.add("3");

/*      To add an element at the specified index of ArrayList use      void add(int index, Object obj) method.      This method inserts the specified element at the specified index in the      ArrayList.      */   

 arrayList.add(1,"INSERTED ELEMENT");    

 /*      Please note that add method DOES NOT overwrites the element previously      at the specified index in the list. It shifts the elements to right side      and increasing the list size by 1.    */    

System.out.println("ArrayList contains...");    
//display elements of ArrayList    
for(int index=0; index < arrayList.size(); index++)   
System.out.println(arrayList.get(index));  
 }
}




***********************************************************************

//AppendAllElementsOfOtherCollectionToArrayListExample
import java.util.ArrayList;
import java.util.Vector;
public class co3  
{   
public static void main(String[] args) 

 //create an ArrayList object
ArrayList arrayList = new ArrayList();     
//Add elements to Arraylist    
arrayList.add("1");    
arrayList.add("2");    
arrayList.add("3");     

//create a new Vector object    
Vector v = new Vector();    
v.add("4");    
v.add("5");     
/*      To append all elements of another Collection to ArrayList use      boolean addAll(Collection c) method.      It returns true if the ArrayList was changed by the method call.    */     
//append all elements of Vector to ArrayList    
arrayList.addAll(v);     

//display elements of ArrayList    
System.out.println("After appending all elements of Vector, ArrayList contains..");    
for(int i=0; i<arrayList.size(); i++)      
System.out.println(arrayList.get(i));   
}} 

/*Output would beAfter appending all elements of Vector, ArrayList contains..12345*/


**********************************************************************************

//CopyElementsOfArrayListToArrayExample
import java.util.ArrayList; 
public class  co4
{   
public static void main(String[] args) 
{    
//create an ArrayList object   
 ArrayList arrayList = new ArrayList();     
//Add elements to ArrayList    
arrayList.add("1");    
arrayList.add("2");    
arrayList.add("3");    
arrayList.add("4");    
arrayList.add("5");     
/*      To copy all elements of java ArrayList object into array use      Object[] toArray() method.    */     
Object[] objArray = arrayList.toArray();     
//display contents of Object array    
System.out.println("ArrayList elements are copied into an Array.                                                    Now Array Contains..");    
for(int index=0; index < objArray.length ; index++)      System.out.println(objArray[index]);  }}


**********************************************************************************


//GetSizeOfArrayListExample 
import java.util.ArrayList; 
public class co5
{   
public static void main(String[] args) 
{  
 //create an ArrayList object    
ArrayList arrayList = new ArrayList();     
//Add elements to Arraylist using    
arrayList.add("1");    
arrayList.add("2");    
arrayList.add("3");     
//To get size of Java ArrayList use int size() method    
int totalElements = arrayList.size();     
System.out.println("ArrayList contains...");    
//loop through it    
for(int index=0; index < totalElements; index++)      System.out.println(arrayList.get(index));   
}
}

************************************************************************

//GetSubListOfJavaArrayListExample
import java.util.ArrayList;
import java.util.List; 
public class  co6
{   
public static void main(String[] args) 
{     
//create an ArrayList object    
ArrayList arrayList = new ArrayList();     
//Add elements to Arraylist    
arrayList.add("1");    
arrayList.add("2");    
arrayList.add("3");    
arrayList.add("4");    
arrayList.add("5");     
/*       To get a sub list of Java ArrayList use       List subList(int startIndex, int endIndex) method.       This method returns an object of type List containing elements from       startIndex to endIndex - 1.    */     

List lst = arrayList.subList(1,3);    

 //display elements of sub list.    
System.out.println("Sub list contains : ");    
for(int i=0; i< lst.size() ; i++)    
 System.out.println(lst.get(i));    
 /*      Sub List returned by subList method is backed by original Arraylist. So any      changes made to sub list will also be REFLECTED in the original Arraylist.    */  
  //remove one element from sub list    
Object obj = lst.remove(0);    
System.out.println(obj + " is removed from sub list");    
 //print original ArrayList    
System.out.println("After removing " + obj + " from sub list, original ArrayList contains : ");    for(int i=0; i< arrayList.size() ; i++)      
System.out.println(arrayList.get(i)); 
  }
}










No comments:

Post a Comment