1 Reply Latest reply on Sep 7, 2019 10:54 PM by OrhanCemalDuru

    String and character array difference

    HariNagarjuna

      This is what I understood about difference between strings and array of characters so far and unicode(U+0000 to U+FFFF).

      1.Unicode of BMP is combination of 0's and 1's and gives 65,536(2^16 or 16^4) characters.

      2.character array can only contain this 65,536 BMP unicode characters.

      3.String can have things other than unicode characters in BMP(65,536 characters).

      please correct me if I am wrong.

        • 1. Re: String and character array difference
          OrhanCemalDuru

          Character encoding tables vary, the class String is, as far as I am concerned, capable of displaying, formatting, and manipulating characters of any encoding type.

          The numbers you give relate to INTEGER_MAX value which also applies to memory allocation of arrays (taking into account the data type). For instance if you have a byte array of length INTEGER_MAX, you get INTEGER_MAX bytes of memory allocated for use. I'm not sure if all encoding tables use a fixed amount of memory, ones I know use a single byte for a single character. So there are 2^8 possible different representations for each character set. That makes 256 unique representations.