+ 9
Splitting a string
/*I can seem to understand whats happening inside the str.split method as" \n" dosent seem to be doing anything..*/ public class Program { public static void main(String[] args) { String str = "abc def ghi" ; String[] strArr = str.split("\n"); //<<<here for(int x = 0; x < strArr.length;++x){ System.out.print(strArr[x]); } } }
5 Answers
+ 11
Because \n is character for new line and you have just one line String.
+ 6
does it treat it like a space similer to this> " " then?
+ 2
Yep
+ 1
Use \s