From 6836a9d3cd61a3b235ace1eb649d747f481b4b9b Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 13 Apr 2016 23:10:14 +0200 Subject: [PATCH] Use string builder --- src/org/mxchange/jusercore/model/user/UserUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(); } /** -- 2.39.5