Which method of java.lang.String
should I use to split the string below into an array or collection of strings, the splitting being done with respect to the character of the line break?
String str="This is a string\nthis is the next line.\nHello World.";
I think that method is split()
.
String[] arrOfStr = str.split("\n", limit)
;
but I don't know what to put in the limit
in order to follow the requirements.
I did that code:
public class Split {
public static void main(String[] args) {
String str="This is a string\nthis is the next line.\nHello World.";
String[] arrOfStr = str.split("\n");
System.out.println(arrOfStr);
}
}
But the result is [Ljava.lang.String;@36baf30c I don't understand.