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