Activity 1.3.1.
Run this code to see the output below it. How would you change it to print the ! on the same line as Hi there keeping all 3 print statements?
System.out.println("Hi there!"); prints out the characters between the first " and the second " followed by a new line. The "Hi there!" is called a string literal which is zero to many characters enclosed in starting and ending double quotes. A literal is the code representation of a fixed value, which can be a string or a numerical value.
" character? Since " is a special character with a meaning in Java string literals, we put in a backslash (\") in front of the quote to signal that we want just the quote character. This is called a backslash escape sequence. And if you wanted to print out a backslash, you would have to backslash (\\) it too in order to escape its special meaning. Another useful backslashed character is \n which will put in a newline.
2 + 3 evaluates to 5.
+), subtraction (-), and division (/). The multiplication operator is written as *, as it is in most programming languages, since the character sets used until relatively recently didnβt have a character for a real multiplication sign, Γ, and keyboards still donβt have a key for it. For similar reasons the Γ· symbol is not used in Java. (You may have noticed that + was also used to combine String and other values into new Strings. More on this later.)
int or double. An arithmetic expression consisting only of int values will evaluate to an int value. An arithmetic expression that uses at least one double value will evaluate to a double value. This means that when you are doing division with two integers, you will get an integer result and the decimal part of the result will be thrown away. This is called truncating division. If you want a double result, you should make at least one of the values in the expression a double like 2.0.
*, division /, and remainder % are done before addition + and subtraction -. However, anything in parentheses is done first. It doesnβt hurt to put in extra parentheses if you are unsure as to what will be done first or just to make it more clear.
% in Java is the remainder operator. Like the other arithmetic operators it takes two operands. Mathematically it returns the remainder after dividing the first number by the second, using truncating integer division. For instance, 5 % 2 evaluates to 1 since 2 goes into 5 two times with a remainder of 1.
% operator. In the figures below, the remainders are the same values that would be returned by 2 % 3 and 5 % 2.

% the modulo, or mod, operator. That is not actually correct though the difference between remainder and modulo, which uses Euclidean division instead of truncating integer division, only matters when negative operands are involved and the signs of the operands differ. With positive operands, remainder and mod give the same results. Java does have a method Math.floorMod in the Math class if you need to use modulo instead of remainder, but % is all you need in the AP exam.

System.out.print and System.out.println are Java output statements that display information on the computer screen. System.out.println moves the cursor to a new line after the information has been displayed, while System.out.print does not.
\ and have a special meaning in Java. Escape sequences used in this course include double quote \", backslash \\, and newline\n.
int and double.
+, -, * , /, and % also known as addition, subtraction, multiplication, division, and remainder.
int values will evaluate to an int value. With integer division, any decimal part in the result will be thrown away.
double value will evaluate to a double value.
*, /, % have precedence over + and -, unless parentheses are used to group those to be evaluated first. Operators with the same precedence are evaluated from left to right.
ArithmeticException.
System.out.print("Java is ");
System.out.println("fun ");
System.out.print("and cool!");
Java is fun and cool!
Java isfun and cool!
Java is fun and cool!
Java is fun and cool!
System.out.println(5 + 5 / 2 * 3 - 1);