Advertisement
Guest User

Untitled

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