Hi All,
Can anyone kindly tell me how to create a synchronized arraylist? Below mentioned is a line of code that i bumped into some site while searching about how to synchronize an array list'
List<String> syncList = Collections.synchronizedList(new ArrayList<String>());.
But when i tried using that code i faced compile time error >>> incompatible types.
I tried the below code on my own and kindly tell me will it work?
import java.util.*;
class AList
{
public static void main(String[] agrs)
{
ArrayList <String> al = new ArrayList<String>();
al.add("john");
al.add("max");
for(String s : al)
{
Collections.synchronizedList(s);
System.out.println(s);
}
}
}
Now is the above code valid
