The character is not surrounded by apostrophes. It should be: 'W'
.
With double quotes, "W"
, you get a String
that contains a single character.
This is not the same as a primitive single character.
A String
is represented as an object and may consist of several hundred bytes.
A primitive character data item is always only two bytes.
boolean
Another of the primitive data types is the type boolean
.
It is used to represent a single true/false value.
A boolean
value can have only one of two values:
true false
In a Java program,
the words true
and false
always mean these
boolean
values.
The data type boolean
is named after George Boole,
a nineteenth century mathematician,
who discovered that a great many things can be done with
true/false values (otherwise known as bits).
Would you like a data type named after you someday?
true false