Prints

Printing messages is one of the most important thing in Web pages, games, and other programs. So if you are about to start java, you should practice how to print messeges and get used to it.

code format="java" System.out.print("Hello Java."); code

This code will print Hello Java.

What if you want to print "Hello Java." including the quotation marks?

\, or backslash can "mute" the meaning of the a letter or a symbol and print it as is without affecting the code itself.

So,

code format="java" System.out.print("\"Hello Java.\""); code

will print "Hello Java."

Also, if you need a tab in your message, simply insert, \t, to tab.

In some cases a new line is necessary and in order to do so, insert, \n.

If you want to have a backslash (\) print as well, you need another backslash in front of it in order to print it. ex. to print "\\//^-^\\//" you need to use this code: code format="java" System.out.print("\\\\^-^\\\\"); code

quotation marks and backslashes need to have a backslash in front of them in order to print them. a forward slash can be used without the backslash in front of it.

★★ Prints ★★ \t = tab \n = new line \*= longer line of comments \" = double quote \\ = backslashes

Sometimes you might want to print the sum, difference, etc. of numbers. For example, to print out the sentence "1 plus 2 equals 5", you do this(assume we have two already defined variables, **a** and **b**):

code format="java" //Assume a = 1 and b = 2 System.out.print("1 plus 2 equals " + (a + b)); //This code will show "1 plus 2 equals 3"

//Be sure to have a space after "equals" or the sentence will say "1 plus 2 equals3" code

or:

code format="java" //Assume a = 1 and b = 2 System.out.print(a + " plus " + b + " equals " + (a + b)");

//This code will show "1 plus 2 equals 3" //You can use those alphabet letters as variables; it will be convinient.

code

You can use print statements to check the performance of a lfor loop you have created. By printing the variable i and the value of of a int c, you can see how your loop alters after each process. You can also use a print statement to print the value of a slot in your array containing a value you modified. It is necessary to have **a** and **b** in parenthesis so that they are added together. If they were not in parenthesis, the sentence would read "1 plus 2 equals 12".
 * __Additional Uses of Print Statements__**

There is a difference between System.out.print and System.out.println. System.out.print will print everything on one line. System.out.println will print each print on separate lines.
 * __Remember__**