From: Roland Haeder Date: Wed, 13 Apr 2016 21:10:14 +0000 (+0200) Subject: Use string builder X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6836a9d3cd61a3b235ace1eb649d747f481b4b9b;p=juser-core.git Use string builder --- diff --git a/src/org/mxchange/jusercore/model/user/UserUtils.java b/src/org/mxchange/jusercore/model/user/UserUtils.java index 486e20f..740e7e3 100644 --- a/src/org/mxchange/jusercore/model/user/UserUtils.java +++ b/src/org/mxchange/jusercore/model/user/UserUtils.java @@ -71,7 +71,7 @@ public class UserUtils extends BaseFrameworkSystem { } // Init variable - String password = ""; + StringBuilder password = new StringBuilder(length); // Start creating it for (int i = 0; i < length; i++) { @@ -79,14 +79,14 @@ public class UserUtils extends BaseFrameworkSystem { int pos = RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET.length()); // Get char at this position and add it to the final password - password += String.valueOf(PASSWORD_ALPHABET.charAt(pos)); + password.append(String.valueOf(PASSWORD_ALPHABET.charAt(pos))); } // Should have the wanted length assert (password.length() == length) : "Password length " + password.length() + " doesn't match requested: " + length; // Return it - return password; + return password.toString(); } /**