Can you explain this code to me, what does arrays.aslist(job) mean ?
String jobs[] ={"senior","programmeur","project manager"};
LinkedList<String> links = new LinkedList<String>(Arrays.asList(jobs));
From the documentation:
Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray(). The returned list is serializable and implements RandomAccess.
Used to create quick list, like:
List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");
See here
The arrays.aslist(job) is converting your String array to a List. The Javadoc for Arrays.asList says
Returns a fixed-size list backed by the specified array.
What it does is
List<String>, basically original array is now available as new listnew LinkedList<String>() it copies all elements from the original array to new List. It creates a immutable copy of the original arrayArrays.asList() creates an immutable List from an array.
To get a mutable List from an immutable List , create a new List (in this case, LinkedList) passing the immutable List in to its constructor.