How to Print Characters in Java
In the Java programming language, applications handle characters by using the Unicode standard encoding. Each Java application has a "standard output," that is, a stream where its output will be sent by default. Programmers can define that standard output to be a console, a network socket or a stream of some other sort -- the same application code will handle all cases without modification. You can print characters by having your Java application send them to standard output.
Instructions
-
-
1
Include the following line at the beginning of your Java code:
import java.lang.System;
-
2
Send standard ASCII characters to standard output by reading them from keyboard input or by including literals as part of program text, as in the following example:
String myASCIIString = "quick brown fox";
System.out.println(myASCIIString);
Stream "System.out" is, by convention, the standard output available to your Java code.
-
-
3
Send non-printable characters to standard output by storing them into Java variables using the Unicode escape sequence. Java represents Unicode characters using the Basic Multilingual Plane (BMP), a 16-bit encoding. The following sample code assigns the Aleph character (first letter of the Hebrew alphabet) to a string, and prints it out on standard output:
String myNonASCIIString = "\u05D0";
System.out.println(myNonASCIIString);
-
1