Google News
logo
Java Collections - Interview Questions
How will you convert a string array to an ArrayList?
This is a beginner’s level programming question that an interviewer asks to check your grasp of Collection utility.classes. Collection and Arrays are the two utility classes of the Collection Framework that interviewers are often interested in.
 
Collections offer certain static functions for performing specific tasks on collection types. While Array has utility functions that it performs on array types.
//String array  
String[] num_words = {"one", "two", "three", "four", "five"};
//Use java.util.Arrays class to convert to list 
List wordList = Arrays.asList(num_words);
Advertisement