Shift Operators

Shift operators are applied only to integer types.

Conditional Operator

The conditional operator ? : uses the boolean value of one expression to decide which of the two other expressions should be evaluated.

exp1 ? exp2 : exp3

If exp1 is true, then exp2 is chosen. If exp1 is false then exp3 is chosen.

Operator Precedence

In Appendix C of your book you have a chart showing the list of operators in Java and their precedence. When two operators have the same precedence, their associativity determines the order of evaluation. All binary operators are left associative. The assignment operators are right associative.

Operand Evaluation Order

The left hand operand of a binary operator is evaluated before any part of the right hand operand is evaluated. The order for evaluating operands takes precedence over the operator precedence rule.

Strings

A String is a sequence of characters. In Java String is a class from which you make String objects, like:
String name = "Alan Turing";
String course = "CS 303E";
String ssn = "123456789";

A String has an associated length. To obtain the length of a String do:

int nameLen = name.length();

You can also concatenate two Strings to get a third String using the + operator.

String zip9 = "78712" + "-" + "1059";

You can convert data that is entered as a primitive type into a String by using the valueOf() method.

int i = 10;
String ten = String.valueOf ( i );

Basic Output

In Java there are no I/O statements in the Java language. The I/O methods belong to classes in the java.io package. Any source or destination for I/O is considered a stream of bytes. There are three objects that can be used for input and output.

The System.out object has two methods - print() and println(). The println() method will print a carriage return and line feed after printing so that the next output will be printed on a new line. The method print() will keep the cursor on the same line after printing.