Created
June 5, 2016 21:16
-
-
Save arose13/0c71381a67897717b866c0b8c9f01eba to your computer and use it in GitHub Desktop.
Gets all the unique characters from a string in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Find all unique characters in the string | |
String uniqueLettersInTestString = ""; | |
for (int i = 0; i < testString.length(); i++) { | |
if (!uniqueLettersInTestString.contains(String.valueOf(testString.charAt(i)))) { | |
uniqueLettersInTestString = uniqueLettersInTestString + String.valueOf(testString.charAt(i)); | |
} | |
} | |
System.out.println("Unique Letters are: " + uniqueLettersInTestString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment