Solved Printing all strings of ArrayList<String> by line

Discussion in 'Plugin Development' started by stimoze, Jul 31, 2016.

Thread Status:
Not open for further replies.
  1. The title says it all. I want to add strings to the arraylist by commands, but the problem is that i can't print it cause it's an ArrayList<String> and it only can print String.
    How can I print strings in arraylist like one string by line? What's the best way for it?
    Is this even possible? If so please help me!

    Here's an example code:

    Bukkit.broadcastMessage(MY ARRAYLIST HERE);
    I know right this isn't possible cause the "MY ARRAYLIST HERE" part is an ArrayList but what the broadcastMessage() method needs, is a String.
  2. Offline


    I would just loop through the arraylist and then broadcast. If you want it all on one line, you could use StringJoiner or StringBuilder
  3. Offline


    He want to print it line by line, meaning iterate over it and broadcast the string you have.
    EDIT: Sorry didn't read it too well, you said the same.
  4. Offline


  5. @stimoze
    for String s : List<String>
    Bukkit.broadcastMessage s
  6. Thank you all guys for help :) Found the best solution.
  7. Offline


    If your problem has been solved, mark this thread as solved.
Thread Status:
Not open for further replies.

Share This Page