Can someone help and explain whether indexOf("") returns 0 is predefined same as -1 by returning a negative result?
Thanks and Happy Easter to all!
ps. the following link was helpful, but it does not contain the exact answer to my question "Hello".indexOf("") returns 0
public class ExIndexOf {
public static void main(String[] args) {
String s = "We learn Java.";
System.out.println(s.indexOf("ava")); // -> 10
System.out.println(s.indexOf("java")); // -1
System.out.println(s.indexOf(" ")); // -> 2
System.out.println(s.indexOf("")); // -> 0
}
}