In the first Java program we created:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
System.out.println("Hello World!");
is responsible for outputting words to the screen.
The function: System.out.println( );
is part of the Input/Output library of to the Java language and is used to output text to the screen.
Input/Output streams (I/O streams) are clearly necessary in order to do anything useful in Java.
The function " System.out.println( );" takes a string, or a number as a parameter. Additionally you can "build a string" by using the "+" operator.
For example:
String x = "Paul";
System.out.println("hello " + x );
This code will print out the phrase "hello Paul"
Printing special characters using the System.out.println( ) function:
Certain ASCII characters that are difficult to represent in a string either because they are not viewable (like an enter key) or because they are part of the formatting of strings in Java (like a " or a ' or a \ ). In order to display these characters, you must represent them using a character code or "control code" in the string that you are including them in. Shown below is a list of some common "control codes".