Java Operators and Statements

Слайд 2

Consider the following points Operators Statements

Consider the following points

Operators
Statements

Слайд 3

Arithmetic Operators * : Multiplication / : Division % : Modulo

Arithmetic Operators

* : Multiplication
/ : Division
% : Modulo
+ : Addition
- :

Subtraction
Слайд 4

Unary Operators – : Unary minus, used for negating the values.

Unary Operators

– : Unary minus, used for negating the values.
+ :

Unary plus, used for giving positive values. Only used when deliberately converting a negative value to positive.
++ : Increment operator, used for incrementing the value by 1. There are two varieties of increment operator.
Post-increment : Value is first used for computing the result and then incremented.
Pre-increment : Value is incremented first and then result is computed.
-- : Decrement operator, used for decrementing the value by 1. There are two varieties of decrement operator.
Post-decrement : Value is first used for computing the result and then decremented.
Pre-decrement : Value is decremented first and then result is computed.
! : Logical not operator, used for inverting a Boolean value.
Слайд 5

Assignment Operators += : for adding left operand with right operand

Assignment Operators

+= : for adding left operand with right operand and

then assigning it to variable on the left.
-= : for subtracting left operand with right operand and then assigning it to variable on the left.
*= : for multiplying left operand with right operand and then assigning it to variable on the left.
/= : for dividing left operand with right operand and then assigning it to variable on the left.
%= : for assigning modulo of left operand with right operand and then assigning it to variable on the left.
Слайд 6

Relational Operators != : Not Equal to : returns true of

Relational Operators

!= : Not Equal to : returns true of left

hand side is not equal to right hand side.
< : less than : returns true of left hand side is less than right hand side.
<= : less than or equal to : returns true of left hand side is less than or equal to right hand side.
> : Greater than : returns true of left hand side is greater than right hand side.
>= : Greater than or equal to: returns true of left hand side is greater than or equal to right hand side.
Слайд 7

if statement

if statement

Слайд 8

if..else statement

if..else statement

Слайд 9

Nested if statement

Nested if statement

Слайд 10

If-else-if statement

If-else-if statement

Слайд 11

Swith-case statement Expression can be of type byte, short, int char

Swith-case statement

Expression can be of type byte, short, int char or

an enumeration. Beginning with JDK7, expression can also be of type String.
Duplicate case values are not allowed.
The default statement is optional.
The break statement is used inside the switch to terminate a statement sequence.
The break statement is optional. If omitted, execution will continue on into the next case.
Слайд 12

Logical Operators && : Logical AND : returns true when both

Logical Operators

&& : Logical AND : returns true when both conditions

are true.
|| : Logical OR : returns true if at least one condition is true.
Слайд 13

Ternary Operator FORM: BooleanExpression ? Expression1 : expression2 Data types of expressions can be different

Ternary Operator

FORM: BooleanExpression ? Expression1 : expression2

Data types of expressions can

be different
Слайд 14

The while statement

The while statement

Слайд 15

The do-while statement

The do-while statement

Слайд 16

The for statement

The for statement

Слайд 17

The for-each statement

The for-each statement

Слайд 18

Nested Loops

Nested Loops

Слайд 19

Optional Labels

Optional Labels

Слайд 20

break, continue, return

break, continue, return