Can negative one be used as the end index for string.substring in Java?
Example:
String str = "test";
str.substring(0, str.indexOf("q"));
Edit: Nowhere in the javadocs does it say directly that endindex cannot be negative. There are implementations of substring in other languages and libraries that allow a negative endindex but disallow a negative beginindex, so it seems relevant that this be explicitly stated. It is not in any way implied either. (Edit: ok it is implied loosely, but I and apparently others who have asked me this question in person still find it pretty unclear. This was meant to be a simple Q+A that I provided not me actually trying to find an answer to this trivial question)