I was wondering why Java and other programming languages implement (seemingly) redundant functions such as:
"foobar".startsWith("bar", 3);
// same as
"foobar".substring(3).startsWith("bar");
// or even indexOf(str, offset), regionMatches(...)
Is there a reason behind this?
substring
throws if the index is out of range.startsWith
just returns false.