From 278e073eb0891281811b9d20545c8d3404775942 Mon Sep 17 00:00:00 2001 From: yennanliu Date: Wed, 13 Mar 2024 09:01:33 +0800 Subject: [PATCH] add stringUtil --- src/main/java/utils/StringUtil.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/utils/StringUtil.java diff --git a/src/main/java/utils/StringUtil.java b/src/main/java/utils/StringUtil.java new file mode 100644 index 00000000..b69fc31a --- /dev/null +++ b/src/main/java/utils/StringUtil.java @@ -0,0 +1,19 @@ +package utils; + +public class StringUtil { + + // https://stackoverflow.com/questions/2255500/can-i-multiply-strings-in-java-to-repeat-sequence + private String multiplyStr(String s, int multiply){ + StringBuilder r = new StringBuilder(); + for (int i = 0; i < multiply; i++){ + r.append(s); + } + return r.toString(); + } + +// public static void main(String[] args) { +// String res = multiplyStr("0", 3); +// System.out.println(res); +// } + +}