char
This type is a 16-bit unsigned quantity that is used to represent text characters. You'd use this to hold a single character. If you want to store several successive characters, such as a name or an address or phone number, you would use the predefined type String, which keeps track of multiple consecutive characters at once. String is a class in the java.lang package, not a primitive type. We'll get to String a little later.
The type char has been made 16 bits long because that's what you need to support character sets from every locale in the world. The USA can get by with just 7-bit ASCII, and Western Europe is fine with 8-bit ISO 8859-1 characters giving a few accented characters. Many other places such as China, Korea, India, and ...
Get Just Java™ 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.