자바 캐릭터 타입에 대한 내용입니다..
A char is a single character, that is a letter, a digit, a punctuation mark, a tab, a space or something similar. A char literal is a single one character enclosed in single quote marks like this
char myCharacter = 'g';
Some characters are hard to type. For these Java provides escape sequences. This is a backslash followed by an alphanumeric code. For instance '\n' is the newline character. '\t' is the tab character. '\\' is the backslash itself. The following escape sequences are defined:
| \b | backspace |
| \t | tab |
| \n | linefeed |
| \f | formfeed |
| \r | carriage return |
| \" | double quote, " |
| \' | single quote, ' |
| \\ | backslash, \ |
The double quote escape sequence is used mainly inside strings where it would otherwise terminate the string. For instance
System.out.println("And then Jim said, \"Who's at the door?\"");
It isn't necessary to escape the double quote inside single quotes. The following line is legal in Java
char doublequote = '"';
'Java' 카테고리의 다른 글
| Generic Method 및 익셉션 처리 팁 (0) | 2008/02/14 |
|---|---|
| Initializing Collection (0) | 2008/02/14 |
| Java char data type (0) | 2008/02/13 |
| Java I/O 성능 향상을 위한 버전(JVM)별 내용 (0) | 2008/02/12 |
| Syntax elements for SimpleDateFormat (0) | 2008/02/11 |