Arrays.asList();
List<String> list = Arrays.asList(a);How to convert this array to ArrayList?
String a[]
= new String[] { "A", "B", "C", "D" };Arrays.asList(a);
Can we add a new string to followoing list?
List<String> list = Arrays.asList(a);
When we need a fixed size mutable collection we go for Array
And that’s the key point here: An array is not a Collection. The Arrays.asList method mainly serves as a “bridge” between the “arrays world” and the “collections world”.
What is the difference between ArrayList al1 and al2?
String[] geeks = {“Rahul”, “Utkarsh”, “Shubham”, “Neelam”};
List<String> al1 = new ArrayList<String>(Arrays.asList(geeks));</String></String>
List<String> al2 = Arrays.asList(geeks);</String>
Collections.addAll();
How to split words of string?
String str = “geekss@for@geekss”;
String[] arrOfStr = str.split(“@”, 2);
Split it into array of strings. The array should not contain any sapace
Hello Vivek How Are you ?
str.split(“//s+”);
Convert ArrayList<String> to String with a dilimter.</String>
How to remove leading and trailing spaces in a String?
str.trim();