Collections arraylist

Collections arraylist

how we can make array list as syncronised....and what will be the code for that?
View Answers

May 7, 2010 at 3:21 PM

Hi Friend,

Try the following code:

import java.util.*;
class SynchronizedArrayList{
public static void main(String[] args)
{
ArrayList al=new ArrayList();
al.add("1");
al.add("2");
al.add("3");
List list = Collections.synchronizedList(al);

synchronized(list) {
Iterator i = list.iterator();
while (i.hasNext()){
System.out.println(i.next());
}
}
}
}

Thanks









Related Tutorials/Questions & Answers:
creating own ArrayList without Collections?
creating own ArrayList without Collections?  How can we write our own arraylist without using collections in JAVA
Collections arraylist - Java Interview Questions
Collections arraylist  how we can make array list as syncronised....and what will be the code for that?  Hi Friend, Try the following... main(String[] args) { ArrayList al=new ArrayList(); al.add("1"); al.add("2
Advertisements
collections
collections  in collections can we perform binarysearch on arraylist elements without sorting them
arraylist
arraylist   Using arraylist class , what type of exception are throws, how can write a java programe   An ArrayList can throw... ArraylistException { void buildAlphabet() { ArrayList list = new ArrayList
ArrayList
ArrayList  import java.util.*; class ArrayListDemo2 { public static void main(String args[]) { ArrayList al=new ArrayList(); al.add("one"); al.add("two"); al.add("three"); al.add("four"); for(int i=0;i Expected
arraylist
arraylist  Hi How can we eliminet duplicate element from arraylist? How can we find highest salary from arraylist ? How can we highest key value pair from map? Thanks Kalins Naik   Remove duplicates from Arraylist
arraylist
arraylist  Hi how can we eliminet duplicate element from arraylist in java? how can we achieve data abstrcation and encapulation in java? how many type of modifier are there in java? Thanks kalins anik   Remove
arraylist
arraylist  Hi i have class A , i have added employee name and id in arraylist, then how can i find out all infomation of class A using emplyee... data into an arraylist and display the data of the particular employee according
arraylist
% *(noOfYearService/2). Store each employee information in different arrayList depending on his
arraylist of an arraylist
arraylist of an arraylist  Can anyone suggest me how to use arraylist of an arraylist?? how to put data into it and get data from it???? becoz i want to make rows and column dynamic which can grow as per requirement?????/ plz
Collections
Collections  Hi, Please send a study material on collections.../java/jdk6/introduction-collections-api.shtml http://www.roseindia.net/javacodeexamples/index.shtml http://www.devmanuals.com/tutorials/java/collections/index.html
collections
collections  1.Create an ArrayList of Object Planet with instance variable name and colour. Add 5 planets to the ArrayList planetList. Sort the ArrayList in ascending order of name and descending order of colour using comparator
collections
collections  why we need collections.when we will use collections in our applications
collections
*/ public static void main(String as[]) { ArrayList al= new ArrayList... code, an object of ArrayList is created. The method add() then adds an integer
Collections in Java
Collections in Java are data-structures primarily defined through a set of classes and interface and used by Java professionals. Some collections in Java that are defined in Java collection framework are: Vectors, ArrayList, HashMap
arraylist and vector
arraylist and vector  what is the diff b/w arraylist and vector
Java ArrayList
Java ArrayList   How to declare unique ArrayList
ArrayList and Vector
ArrayList and Vector  hello, Why ArrayList is faster than Vector?   hii,ADS_TO_REPLACE_1 ArrayList is faster than Vector, because ArrayList is not synchronized. Synchronization will reduce the performance of Vector
arraylist in java
arraylist in java  arraylist in java   Array List Example in java
ArrayList object
ArrayList object  i have am ArrayList object it containg data base records in it, now i want to display this ArrayList object data in my jsp programe, plz help me
what is collections?
what is collections?  what is collections
ArrayList elements
ArrayList elements  how to print ArrayList elements in reverse order... ArrayListReverse { public static void main(String[] args) { ArrayList list=new ArrayList(); list.add("Innova"); list.add("Alto
Java arraylist of arraylist
Java arrayList can make the use of other arrayList.  In one arrayList other arrayList can be added as the object  It works as two dimension array. Example of Java Arraylist of Arraylist import
comparing arraylist of an multi dimensional arraylist
comparing arraylist of an multi dimensional arraylist  can anyone help me in solving the following issue: actually i have an arraylist called dany... have to compare each arraylist with each other. like i have to take 1st arraylist
accessor arrayList
accessor arrayList  how to use an acccessor to return an arraylist?   public List getProductList(String itemName) { List list=new ArrayList(); //Add your item in the list return list; } You may wish to browse
Collections API
Collections API  hello, What is the Collections API?   hiADS_TO_REPLACE_1 The Collections API is a set of classes and interfaces that support operations on collections of objects
ArrayList in java
ArrayList in java  sir i have a class Student.it contains id,name,marks of students and a parameteraised constructor.now i created an arraylist... to access marks from arraylist
ArrayList programe
ArrayList programe  How to write a java program to accept an array list of Employee objects. search,delete and modify a particular Employee based on Id Number (like ID,Name&Address
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain... StudentsManager's methods statically. studByYear(year); returns an ArrayList of all
vector and arraylist
vector and arraylist    suppose i have class A { public static arrylist a1(){} class B{ public static vector b1() {} } my question is how to class B method in Class A and how to get vector object values in class A without
How to create new arraylist using Java
/collections/arraylist/newarraylist.html Thanks...How to create new arraylist using Java  hi, I want to develop an small application where i trying to create new arraylist inside the arraylist. Can
collections - Java Interview Questions
in Array of type Integer. Collections : ArrayList al = new ArrayList...)); This show n element store in ArrayList not specify.It can be resizable. Thanks
Collections in Java
Collections in Java  What is Concurrent Hash map
Collections in Java
Collections in Java  What is Concurrent Hash map
arraylist problems?
arraylist problems?   myprogram needs to ask the user for a file name. The file will contain a name on each line. Put each of the names into an ArrayList. After you have put all of the names into the ArrayList search through
java arraylist
need to create arraylist whose name is same as type value(e.g : list1,list2... which is having type list1 in the arraylist named list1. the problem here... help how to handle this through java arraylist. xml : <?xml version='1.0
ArrayList
arraylist
arrayList
Java arraylist, linkedlist
Java arraylist, linkedlist  What is the major difference between LinkedList and ArrayList
java collections
java collections  what are all the methods and things added for collections in java5 and java6 please kindly reply me as soon as possible
Version of commons-collections>commons-collections dependency
List of Version of commons-collections>commons-collections dependency
Version of excalibur-collections>excalibur-collections dependency
List of Version of excalibur-collections>excalibur-collections dependency
Remove multiple elements in arraylist
Remove multiple elements in arraylist   how can we remove multiple values in arrayList? only remove method we used for single remove.but i want to delete multiple value in arrayList
Java arraylist sort
ArrayList doesn't have sort() method. We can use the static sort  method of the Collections class It sorts the given Collection object. Example of Java Arraylist Sort import java.util.ArrayList; import
How to convert Arraylist into String Array Java
://www.roseindia.net/tutorial/java/collections/arraylist/arraylisttostringarray.html...How to convert Arraylist into String Array Java  Hi, I am beginners of Java programming. Can somebody Suggest me how to convert arraylist to string
ArrayList as an argument to another class
ArrayList as an argument to another class  how do you pass arraylists as arguments to another class, and how does the method/class accept this arraylist for use
How to Convert ArrayList to Array?
How to Convert ArrayList to Array?  Hi, I am trying to learn to Convert ArrayList to Array. How it is possible? How to Convert ArrayList to Array? Thanks   Hi, To Convert ArrayList to array ArrayList.toArray
Java ArrayList Example
Java ArrayList Example  How can we use array list in java program..."); array.add("Arun"); System.out.println("ArrayList Size...++){ System.out.println("ArrayList Element"+i+" :"+array.get(i
Printing ArrayList - JSP-Servlet
Printing ArrayList   I have a code in servlet like this ArrayList total = new ArrayList (); session.setAttribute("efg",total...(request,response); to print the values in ArrayList total, I did this in my JSP

Ads