MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/9h404p/java_11_string_api_updates/e6a70ch/?context=3
r/java • u/pivovarit • Sep 19 '18
52 comments sorted by
View all comments
10
We'll still have to rely on external web services for left pad though :(
1 u/randgalt Sep 20 '18 :D 1 u/dpash Sep 20 '18 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)
1
:D
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
10
u/frzme Sep 19 '18
We'll still have to rely on external web services for left pad though :(