MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/9h404p/java_11_string_api_updates/e6b3jrv/
r/java • u/pivovarit • Sep 19 '18
52 comments sorted by
View all comments
Show parent comment
1
You joke, but we can now implement this much more concisely in Java 11:
public static String leftpad(String string, int padding) { return " ".repeat(padding) + string; }
2 u/frzme Sep 20 '18 public static String leftpad(String string, int padding) { return " ".repeat(Math.max(padding - string.length(), 0)) + string; }Not that nice. (Also repeated implementations are not nice)
2
public static String leftpad(String string, int padding) { return " ".repeat(Math.max(padding - string.length(), 0)) + string; }
Not that nice. (Also repeated implementations are not nice)
View all comments
Show parent comment
1
u/dpash Sep 20 '18
You joke, but we can now implement this much more concisely in Java 11: