HOME
Learning Objectives
- Develop code to generate output and determine the result that would be displayed
- System.out.print and System.out.println display information on the computer display.
System.out.println moves the cursor to a new line after the information has been displayed while
System.out.print does not
see
an example
- Develop code to utilize string literals and determine the result of using string literals.
- A literal is the code representation of a fixed value.
- A string literal is a sequence of characters enclosed in double quotes.
- Escape sequences are special sequences of characters that can be included in a string. They start
with a \ and have a special meaning in Java. Escape sequences used in this course include double
quote \", backslash \\, and newline \n.
- Develop code for arithmetic expressions and determine the result of these expressions.
- Arithmetic expressions, which consist of numeric values, variables, and operators, include
expressions of type int and double.
- The arithmetic operators consist of addition +, subtraction -, multiplication *, division /, and
remainder %. An arithmetic operation that uses two int values will evaluate to an int value. An
arithmetic operation that uses at least one double value will evaluate to a double value.
- When dividing numeric values that are both int values, the result is only the integer portion of the
quotient. When dividing numeric values that use at least one double value, the result is the
quotient.
- The remainder operator % is used to compute the remainder when one number a is divided by another
number b.
- Operators can be used to construct compound expressions. At compile time, numeric values are
associated with operators according to operator precedence to determine how they
are grouped. Parentheses can be used to modify operator precedence. Multiplication, division, and
remainder have precedence over addition and subtraction. Operators with the same precedence are
evaluated from left to right.
- An attempt to divide an integer by the integer zero will result in an ArithmeticException.
Previous Topic
Next Topic - Assignment Statements and Input