Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main (String [] args) {
- String word = "caramel";
- boolean [] array = new boolean[35];
- for (int i = 0; i < word.length(); i++) {
- char ch = word.charAt(i);
- int k = Character.getNumericValue(ch);
- if (array[k] == true) {
- System.out.println("There is a duplicate.");
- System.exit(0);
- }
- array[k] = true;
- }
- System.out.println("There are all unique characters.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement