Last active
August 29, 2015 14:17
-
-
Save hanaori/914f60842b791725ebab to your computer and use it in GitHub Desktop.
Check whether the string has the same characters in it.
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
public class UniqunessCheck { | |
public boolean isUnique(String str){ | |
boolean isUnique = true; | |
for(int i = 0; i < str.length(); i++){ | |
for(int k = 0; k < str.length(); k++){ | |
if(i != k){ | |
if(str.charAt(i).equals(str.charAt(k))){ | |
isUnique = false; | |
break; | |
} | |
} | |
} | |
} | |
return isUnique; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
引数に渡された文字列に同じキャラクターが含まれないかチェックするメソッド