dcsimg
 

Submitted by: Octavia Anghel(octaviaanghel@gmail.com)

Wednesday May 9th 2018 by Octavia Anghel

Language: Java, Expertise: Beginner - See an example of why you should not assume that char represents only one character.

Do not assume char represents only one character:

"\uD83D\uDC31".length() == 2

The escape sequence represents the Unicode code point 0x1F431 in UTF-16 as 2 chars. So even though this is only a single cat face symbol on the screen, the length() method returns 2.

Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved