Public Staticobject[] List2array (List<Object>Olist) {
object[] Oarray=Olist.toarray (Newobject[] {});
//TODO needs to write another method when it is used, and does not support the array of Generics.
Returnoarray;
}
Public Staticobject[] Set2array (Set<Object>Oset) {
object[] Oarray=Oset.toarray (Newobject[] {});
//TODO needs to write another method when it is used, and does not support the array of Generics.
Returnoarray;
}
Public Static <TExtendsObject>List<T>Set2list (Set<T>Oset) {
List<T>TList= NewArrayList<T>(oset);
//TODO needs to write another construct when it is used, and generate the corresponding subclass of the list as Needed.
ReturntList;
}
Public Static <TExtendsObject>List<T>Array2list (t[] Tarray) {
List<T>TList=Arrays.aslist (tarray);
//TODO Simple Aslist () The returned tlist cannot add (), remove (), clear () and other actions that affect the number of collections,
//Because Arrays$arraylist and java.util.ArrayList are the same, they inherit abstractlist,
//But Arrays$arraylist did not override these methods, and Java.util.ArrayList implemented Them.
//TODO recommends using the subclass of list to do the return instead of Arrays$arraylist. If you need it. Comments such as the Downlink:
//list<t> tList = new arraylist<t> (arrays.aslist (tarray));
ReturntList;
}
Public Static <TExtendsObject>Set<T>List2set (List<T>TList) {
Set<T>Tset= NewHashSet<T>(tList);
//TODO-specific implementations look at the need to convert a subclass of a different set.
Returntset;
}
Public Static <TExtendsObject>Set<t> Array2set (t[] Tarray) {
set<t> tset = new Hashset<t< Span style= "color: #000000;" >> // TODO There is no one step method, according to the specific function, select the appropriate set subclass to Convert.
return tset;
} /span>
Set,list,array (collections and Arrays) in Java are converted to each other