DEV Community

Discussion on: Be Careful with String’s Substring Method in Java

 
6502 profile image
Andrea Griffini

I thought you were asking for comments, so I commented.

I think the view that substring in Java has a "quirk" because uses the [a, b[ convention for intervals is questionable.

That "semi-open interval" is in my opinion the correct approach (may be on par or second only to a start/size approach). A "boundary included" [a, b] would instead be worse for many reasons.

Java has no "quirk" here: it's the correct thing to do (and please note that I'm surely NOT a Java fan, at all).