Can anyone tell me why this is working well:
String wanttosplit = "asdf...23\n..asd12";
String[] i = wanttosplit.split("\n");
output are:
i[0] = asdf...23
i[1] = ..asd12
When i want to get the data from user like:
import java.util.Scanner;
Scanner scan = new Scanner(System.in);
String wanttosplit = scan.next(); //user enter asdf...23\n..asd12 on the keyboard
String[] i = wanttosplit.split("\n");
output are:
i[0] = asdf...23\n..asd12
Why it didnt split like in first example?