Detailed explanation of mutual conversion between Java list, set, map and array
Detailed explanation of mutual conversion between Java list, set, map and array
1. List to set
2. Set to list
3. Convert array to list
At this point, there are three elements in stooges. Note: the list cannot be added at this time, otherwise it will report "java.lang.unsupportedoperationexception", arrays Aslist() returns a list with a fixed length, so it cannot be converted to ArrayList, but can only be converted to abstractlist
The reason is that the aslist () method returns the list form of an array. The returned list is just another view of the array, and the array itself does not disappear. Any operation on the list is finally reflected on the array Therefore, the method of remove and add is not supported
4. Convert array to set
5. Map related operations.
6. List to array
Thank you for reading, hope to help you, thank you for your support to this site!