Skip to content

Instantly share code, notes, and snippets.

@XDo0
Last active November 28, 2021 13:02
Show Gist options
  • Save XDo0/1a5dce773fb847249b876220d59b5818 to your computer and use it in GitHub Desktop.
Save XDo0/1a5dce773fb847249b876220d59b5818 to your computer and use it in GitHub Desktop.
Java Type Conversion
//string 2 list
List<String> l=Arrays.asList(s.split(""));
// array 2 list(except 8 basic types),reference type
List<T> l=Arrays.asList(array);
//8 basic types arrays 2 list, such as Integer
List list=new ArrayList();
double array[]={12,223,234};
for(int i=0;i<array.length;i++){
list.add(new Double(array[i]));
}
//list 2 array
int size =list.size();
String array[]=(String[])list.toArray(new String [size]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment