Solved Converting String[] to spaces list

Discussion in 'Plugin Help/Development/Requests' started by tytwining, Dec 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    I cannot find an easy way to make String[] convert to a list. For example, if there was a list containing [Hello,bob,you,died], I want to convert that into "Hello bob you died"
  2. Offline


    Loop through the list and append a space to a StringBuilder on every iteration

    String[] array; // Your array
    StringBuilder builder = new StringBuilder(""); // Now we want to create a StringBuilder so we can append the strings later
    for (int i = 0; i < array.length; i++) { // Lets loop through the array
    if (i > 0) builder.append(" "); // Since we dont want to add a space if its the first word.
    builder.append(array[i]); // But we obviously also want to add the current word...
    String yourString = builder.toString(); // Now we just need to convert the StringBuilder into a String
  3. Offline


    Last edited: Dec 29, 2014
Thread Status:
Not open for further replies.

Share This Page