Why Java sucks
class SubTest {
public static void main(String args[]) {
String s = "12345";
String subs = s.substring(2, 3);
System.out.println(subs);
}
}
(Ignore those backslash delimiters up at the initial string declaration. That’s a function of WordPress or HTML or something, not my code.)
That code returns:
3
What kind of screwed up language is this? I can understand the first argument to the substring method being the base-0th character in the string. I’m cool with that. That returns “3.” But then the second argument is the last character of the string base-1. That’s just bizarre. Or, as a different book explains it, the second argument is “up to but not including” the base-0th character. Still bizarre, although slightly less ludicrous.
In Perl, you give it the base-0th character and how many characters you wish to excerpt. Simple. Makes sense. Heck, even telling it the first and last character in a string you wish to excerpt would make sense. Not including that last character is just bizarre.
I know every language has its eccentricities and all, but I just needed to vent. I’m sure LISP does it best, too. ;-)
Besides, by writing this all up, I’ve learned it better than just steaming over it privately.
As you were.
