Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Malleshwari
Collections arraylist
1 Answer(s)      4 years and 8 months ago
Posted in : Java Interview Questions


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

Advertisement
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
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  why we need collections.when we will use collections in our applications
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
*/ public static void main(String as[]) { ArrayList al= new ArrayList... code, an object of ArrayList is created. The method add() then adds an integer
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
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
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
what is collections?
what is collections?  what is collections
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
Collections API
Collections API  hello, What is the Collections API?   hi The Collections API is a set of classes and interfaces that support operations on collections of objects
Collections in Java
Collections in Java  What is Concurrent Hash map
Collections in Java
Collections in Java  What is Concurrent Hash map
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
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
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 Framework
Collections Framework  Sir, We know that both HashMap & Hashtable is using for same purposes i.e Used for storing keys-values pair. But there is some difference between this two class that are 1)Hashtable is synchronized
 

 

 

DMCA.com