I am trying to use \n to create a list of strings but whenever I add more than one string, the string indents up to the point of the previous string so an example output would be:
0 hello nain
1 test nain
2 huh nain
I don’t know why its doing this. Here’s the code where I create the string:
String[] posts = currentTopic.getMessages("main");
//String[] postsOutput = new String[posts.length];
String postsOutput = "0 " + posts[0];
for(int i = 1; i < posts.length; i++){
postsOutput += "\n" + i + " " + posts[i];
//postsOutput[i] = i + posts[i];
}
sc.close();
return postsOutput;
I also tried moving the \n to the end of the appending but the result is still the same. Any help would be appreciated.
Thanks
Try \r\n, i.e. carriage return and newline.