Java: convert List to Array

Trabla: Java:  convert List to Array

Solving:

List<String> userList = new ArrayList<String>();
userList.add( "Alex" );
userList.add("Toni");
userList.add("Jack");


String[] users = userList.toArray( new String[ userList.size() ]  );

OR

List<String> userList = new ArrayList<String>();
userList.add( "Alex" );
userList.add("Toni");
userList.add("Jack");


String[] users = new String[ userList.size() ];

userList.toArray( users   );

No comments:

Post a Comment