BCAC-301 - Lecture 4
BCAC-301 - Lecture 4
Operators in J ava
Arithmetic Operator
Relational Operator
Logical Operator
Increment & Decrement Operator
Assignment Operator
Operators in J a v a
3
Relational Operator
Logical Operator
Assignment Operator
Conditional Operator
Bitwise Operator
Instance of Operator
new Operator
Arithmetic Operator
4
++a and a++ means the same thing when they form
statements independently & they behave differently
when they are used in expression or the R . H . S . of a n
assignment statement.
Consider the following example
int x=10,y,z;
y=++x; / / pre-increment
printf (“X=%d Y=%d”, x,y); //X=11 & Y=11
z=x++; / / post-increment
printf (“X=%d Z=%d”, x,z); //X=12 & Z=11
Increment & Decrement Operator (CONTD.)
9
Similarly --a and a-- means the same thing when they form
statements independently & they behave differently when they
are used in expression or the R . H . S . of an assignment statement.
int p=50,q,r;
q=--p; / / pre-decrement