I'm learning to use Java's Pattern and Matcher, and this is an example code snippet in my book. It works as the author describes, but what I don't get is why \\.
ends up being a dot instead of a backslash (the \\ part) and a dot (the . part). Does the compiler not read from left to right?
import java.util.regex.*;
public class SplitTest {
public static void main(String[] args) {
String input= "www.cs.cornell.edu";
Pattern p = Pattern.compile("\\.");
String pieces[] = p.split(input);
for (int i=0; i<pieces.length; i++){
System.out.println(pieces[i]);
}
}
}