ASCII Characters

ASCII Characters

  • int[26] for Letters 'a' - 'z' or 'A' - 'Z'. Usually used as map[ch - 'a']
  • int[128] for ASCII
  • int[256] for Extended ASCII
  • 0 < 9 < A < Z < a < z
  • ASCII 码使用指定的7 位或8 位二进制数组合来表示128 或256 种可能的字符。标准ASCII 码也叫基础ASCII码,使用7 位二进制数来表示所有的大写和小写字母,数字0 到9、标点符号, 以及在美式英语中使用的特殊控制字符

    后128个称为扩展ASCII码。许多基于x86的系统都支持使用扩展(或“高”)ASCII。扩展ASCII 码允许将每个字符的第8 位用于确定附加的128 个特殊符号字符、外来语字母和图形符号

  • 字符'0':char c = '0';   它的ASCII码实际上是48。内存中存放表示:00110000


    字符'' : ASCII码为0,表示一个字符串结束的标志。这是转义字符。


    整数0 :ASCII码为0,字符表示为空字符,NULL;数值表示为0;内存中表示为:00000000

// Implement an algorithm to determine if a string has all unique characters.

public class IsUniqueChar {
    public static void main(String[] args) {
        String s = "abcad";
        System.out.println(isUniqueChars(s));
    }


    public static boolean isUniqueChars(String str) {

        boolean[] char_set = new boolean[256];

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

            int val = str.charAt(i);

            if (char_set[val]) return false;

            char_set[val] = true;

        }

        return true;
    }
}
原文地址:https://www.cnblogs.com/codingforum/p/7451020.html