Public static object [] list2array (list <Object> olist ){
Object [] oarray = olist. toarray (new object [] {});
// When todo is used, another write method is required. The generic array is not supported.
Return oarray;
}
Public static object [] set2array (set <Object> oset ){
Object [] oarray = oset. toarray (new object [] {});
// When todo is used, another write method is required. The generic array is not supported.
Return oarray;
}
Public static <t extends Object> List <t> set2list (set <t> oset ){
List <t> tlist = new arraylist <t> (oset );
// When todo is used, another write structure is required to generate the corresponding subclass of list as needed.
Return tlist;
}
Public static <t extends Object> List <t> array2list (T [] tarray ){
List <t> tlist = arrays. aslist (tarray );
// Some operations that affect the number of sets, such as add (), remove (), clear (), and so on, are not returned by the pure aslist () returned by todo,
// Because arrays $ arraylist is the same as Java. util. arraylist, they all inherit abstractlist,
// But arrays $ arraylist does not have the override methods, while Java. util. arraylist implements.
// Todo we recommend that you use the subclass of list for return, instead of arrays $ arraylist. As needed. Note the following line:
// List <t> tlist = new arraylist <t> (arrays. aslist (tarray ));
Return tlist;
}
Public static <t extends Object> set <t> list2set (list <t> tlist ){
Set <t> tset = new hashset <t> (tlist );
// The specific implementation of todo is converted into sub-classes of different sets.
Return tset;
}
Public static <t extends Object> set <t> array2set (T [] tarray ){
Set <t> tset = new hashset <t> (arrays. aslist (tarray ));
// Todo does not have a one-step method. Based on the specific function, select the appropriate set subclass for conversion.
Return tset;
}