I have a piece of code that has an array passed to it in the form of args[]. args will contain data such as ["Hello", "guys"].
I need to use the sendMessage method to display chat in-game and where I have attempted to create a regular string from my array, what is sent in chat is a '[Ljava.lang.String;@' message instead.
String Msg = new String (args.toString());
OnlinePlayers.sendMessage(ChatColor.GREEN + Player.getName() + ": " + Msg);
Do you know how I can change this code so that the text from the array is put into one string and printed as words and not a weird format that no one understands?
======
New Version
String NewMsg = null;
String Msg = java.util.Arrays.toString(args);
for( int i = 0; i <= Msg.length() - 1; i++) {
NewMsg = (args[i] + " ");
}
OnlinePlayers.sendMessage(ChatColor.GREEN + Player.getName() + ": " + NewMsg);
I'm now just getting errors and it isn't working at all. I thought this would get the amount of separate words from 'Msg.length()' and then iterate through the for loop and add a word plus a space to the 'NewMsg' string each loop.
ArrayList!= array.