Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UniqueLetters {
- public static void main (String args[]) {
- System.out.println(hasUnique("abc"));
- System.out.println(hasUnique("abca"));
- System.out.println(hasUnique("a"));
- }
- public static boolean hasUnique (String word) {
- if (word.length() > 1)
- for (int i=0; i<word.length()-1; i++) {
- for (int j=i+1; j<word.length(); j++)
- if (word.charAt(i) == word.charAt(j))
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement