Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public static void main (String [] args) {
  2.  
  3. String word = "caramel";
  4. HashMap<Character, Integer> map = new HashMap<>();
  5.  
  6. for (int i = 0; i < word.length(); i++) {
  7.  
  8. char ch = word.charAt(i);
  9.  
  10. if (map.get(ch) != null) {
  11. System.out.println("There is a duplicate.");
  12. System.exit(0);
  13. }
  14.  
  15. map.put(ch, 1);
  16. }
  17. System.out.println("There are all unique characters.");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement