How to find a given String have all Unique character.

How to find a given String have all Unique character.
SOURCE : StringUniqueChar.java

public class StringUniqueChar {

public static boolean isbool(String s) {

boolean[] char_set = new boolean[256];

for (int i = 0; i < s.length(); i++) {

int val = s.charAt(i);

if (char_set[val]) {

return false;
}
char_set[val] = true;
}

return true;

}

public static void main(String[] args) {

String s = "this";

isbool(s);
System.out.println(isbool(s));
}

}


INPUT

String s = "this"



OUTPUT

true






Sandeep Kumar D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Sandeep Kumar D

Follow Me @Google+




SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment