Top
Previous Next
The Java Language CS 161 - Java

Other Primitive Types

TypeSizeValues
boolean1 bittrue or false
char16 bitUnicode characters

Example

boolean tOrF = true;
char c = 'a';

boolean

Java has special reserved words related to boolean types

true and false are reserved words in Java

Used to save the result of a relation or conditional operators (discussed later.)

char

A char variable (field) can hold a single Unicode character

Any of over 34,000 distinct characters from the written languages of the Americas, Europe, the Middle East, Africa, India, Asia, and Pacifica.

Java supports using a set of escape sequences to represent frequently used special character values:

Escape sequenceCharacter value
\bBackspace
\tTab character
\nNewline
\rCarriage return
\"Double quote
\'Single quote
\\Backslash
\uxxxThe Unicode character xxxx


Top
Previous Next
jwd