how to detect next line in java code example
Example 1: java string next line
// its \r\n
String a = "Hello, "
String b = "there!"
System.out.println(a+b);//returns Hello, there
System.out.println(a+"\r\n"+b);//returns Hello,
//there! //it will be on the next line!
Example 2: java detect new line in string
String word = "A string \n with a new Line inside"
String newline = System.getProperty("line.separator");
boolean hasNewline = word.contains(newline);
if(hasNewLine){
System.out.println("Enter has been pressed");
}