您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Content Index

Content Page # 35

Character types

There is only one primitive Java type for working with individual characters — the char type.

Examples of char values include:

  • 'm'
  • ' ' (space)
  • '='
  • '5'
  • 'A'

An example of some code declaring and initialising a char variable is as follows:

char carYearLetter = 'A';

Notice the use of single quotation marks for char literal values. This becomes important when working with strings of characters that defined using double quotation marks.

A related concept to the char type, is that of the String class. The relationship between characters and strings is described in the next unit.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg