Java Programming/Keywords/char

From Wikibooks, open books for an open world
< Java Programming | Keywords
Jump to: navigation, search

char is a keyword. It defines a character primitive type.

The java.lang.Character class is the nominal wrapper class when you need to store a char value but an object reference is required.

Syntax:

char <variable-name> = '<character>';

For example:


Computer code
char oneChar1 = 'A';
char oneChar2 = 65;


65 is the numeric representation of character 'A' , or its ASCII code.

Computer code
System.out.println( oneChar1 );
System.out.println( oneChar2 );

outputs the following:

A
A

See also:

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export