diff --git a/Others/PasswordGen.java b/Others/PasswordGen.java index 8d49e6c65633..c41768ad0685 100644 --- a/Others/PasswordGen.java +++ b/Others/PasswordGen.java @@ -35,13 +35,13 @@ static String generatePassword(int min_length, int max_length) { // Inbuilt method to randomly shuffle a elements of a list Collections.shuffle(letters); - String password = ""; + StringBuilder password = new StringBuilder(); // Note that size of the password is also random for (int i = random.nextInt(max_length - min_length) + min_length; i > 0; --i) { - password += letters.get(random.nextInt(letters.size())); + password .append( letters.get(random.nextInt(letters.size()))); } - return password; + return password.toString(); } } diff --git a/README.md b/README.md index d2a467239faa..c77db447f709 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can run and edit the algorithms or contribute to them using Gitpod.io, a fre [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/TheAlgorithms/Java) -### All algorithms are implemented in Java (for education purposes) +### All algorithms are implemented in Java (for educational purposes) These implementations are for learning purposes. The implementations may be less efficient than the Java standard library. ## Contribution Guidelines