Part 3 Type char and double - Type char The values of type...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Type char The values of type char are the characters that you can type on your keyboard, plus many more. Literals of type char are written with single-quote marks surrounding the character. The last example below is the blank, or space character, which you get by stroking the space bar on your keyboard. 'a' 'Z' '<' ' ' Try typing ''' into the DrJava interactions pane, and you are in for a surprise. It produces an error message. The problem is that the second single quote is ambiguous —does it indicate the end of the literal or does it represent the single-quote character? To get around this ambiguity, Java and many other languages use the escape character \ to write characters like the single quote, like this: '\'' The table below lists four characters that are written using the escape character. To see others, look at page 225 of Gries/Gries. character meaning \' the single quote char \" the double quote char \\ the backslash char \n the new-line char You will see how the new-line character is used in the next lecture, on Strings. Representation of characters: ASCII and Unicode You don't have to read the information below on the representation of characters and Unicode. However, it will give you a sense of history and help you understand how inclusive type char is with respect to the world's languages. Representation of characters
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/07/2008 for the course CS 101 taught by Professor Gries during the Spring '08 term at Cornell University (Engineering School).

Page1 / 4

Part 3 Type char and double - Type char The values of type...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online