r/java • • Sep 19 '18

Java 11 String API Updates

https://4comprehension.com/java-11-string-api-updates/
168 Upvotes

52 comments sorted by

View all comments

55

u/TheRedmanCometh Sep 19 '18

Holy shit isBlank should have existed long ago. Strip though is just replace without parameters

2

u/dpash Sep 19 '18

Strip though is just replace without parameters

What do you mean by that?

-2

u/TheRedmanCometh Sep 19 '18

I mean it's essentially String.replace(" ") and it should be called stripWhitespace or stripSpaces

17

u/dpash Sep 19 '18 edited Sep 19 '18

Space is not the only whitespace character, so no, it's nothing like String.replace(" ", "")

Also, .strip() doesn't remove all whitespace, only those at the beginning and end of the string. It's a correctly implemented .trim()

0

u/TheRedmanCometh Sep 19 '18

All other whitespace chars I know of are just unrendered unicode shit. Can you elaborate? Not trying to be dickish I'm sincerely interested

3

u/amackenz2048 Sep 19 '18

Tab?

2

u/TheRedmanCometh Sep 19 '18

Well shit I guess that should've been obvious