Previous | Home | Next |
A character preceded by a backslash (\) is an escape sequence and has special meaning to the compiler.
Escape Sequence | Description |
\t | Inserts a tab in the text at this point. |
\b | Inserts a backspace in the text at this point. |
\n | Inserts a newline in the text at this point. |
\r | Inserts a carriage return in the text at this point. |
\f | Inserts a form feed in the text at this point. |
\' | Inserts a single quote character in the text at this point. |
\" | Inserts a double quote character in the text at this point. |
\\ | Inserts a backslash character in the text at this point. |
Example :
public class Test { public static void main(String args[]) { System.out.println(" \"Hello!\" to me."); } }
output :
"Hello!" to me.
Unicode provides a unique number for every character. Unicode code in Java Programming is a system of encoding characters. all characters and string in java used the Unicode encoding which allows truly international programming. Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages.
Any character in source code can also be represented by its unicode number. By starting with \u followed by its 4 digits hexadecimal code.
Example :
class TestUniEsp static \u0069nt \u611b = 3; public static void main(String[] arg) { System.out.println( \u611b ); } public class Char { public static void main(String[] args) { char a; a = 65; // 65 = Char code for the character 'A' System.out.println(a); // Prints 'A' int i; i = 'A' + 1; // 'A' is just an integer !!! System.out.println(i); // Prints 66 !!! } }
Previous | Home | Next |