In Java’s String.class, I see this
public String substring(int beginIndex, int endIndex){
//if statements
return ((beginIndex == 0) && (endIndex == count)) ? this:
new String (offset + beginIndex, endIndex - beginIndex, value);
}
What is the ‘?’ doing? While we’re on the subject, can anyone explain whats happening with that ‘new String’ in the return statement? Is that some kind of conditional?
It’s a ternary operator and it is equivalent to: