Problem: Write a java program to determine if a string has all unique characters

package in.questionsforinterview.problems;

public class UniqueCharacterChecker {


	// Method #1
	public boolean isUnique1(String s) {
		if (s == null || s.length() > 256) {
			return false;
		}
		boolean[] map = new boolean[256];
		char[] chars = s.toCharArray();
		// ascii number is index of array
		for (char c : chars) {
		// If a character occurs more than once, then the index is true.
			if (map[c]) {
				return false;
			}
		// If a character's index is not true in map[] array, then set it to true. (this happens first  occurrence of the character)
			map[c] = true;
		}
		return true;
	}

	public static void main(String[] args) {
		UniqueCharacterChecker iu = new UniqueCharacterChecker();
		String s = "abc";
		System.out.println(iu.isUnique1(s));
	}
}

Output

true