What is the string
u that is being split? Print it, along with the length and the contents of the array. Perhaps
u does not have the value you think ("htp://www.google.com,gofish" and "htp://www.google.com,go fish")
---
split("\\,") does split the string on commas as can be seen by removing the other logic and looking merely at what split() does.
public class SplitEg {
public static void main(String[] args) {
test("htp://www.google.com,gofish");
test("htp://www.google.com,go fish");
}
private static void test(String str) {
System.out.printf("Looking at -->%s<--%n", str);
String[] arr = str.split("\\,");
System.out.printf("Found %d elements:%n", arr.length);
for(int i = 0; i < arr.length; i++) {
System.out.printf(" -->%s<--%n", arr[i]);
}
}
}