Java, Android software development [Part-27] :: Let's see the Java operators and let's do programming

in #technology7 years ago


Let's know the categories of operators

There are different types of operators in Java. These are:

User operators
Arithmetic Operator
Shift operator
Relational operators
Bit wiite operator
Logical operator
Turnarie operator
Assignment operator
The priority or priority of Java operators

The prevalence of Java operators means that if there is more than one operator in a single station, the continuity of which operator will be operated before and after which it is called priority. Below is a priority table. Before the operator, before its precedence. And after which it is also the priority. So let's see ...

Operator Type Category Precedence
Unary postfix expr ++ expr--
prefix ++ expr --expr + expr -expr ~!
Arithmetic multiplicative * /%
additive + -
Shift shift << >> >>>
Relational comparison <> <=> = instanceof
equality ==! =
Bitwise bitwise AND
bitwise exclusive OR ^
bitwise inclusive OR |
Logical logical AND &&
logical OR ||
Ternary Ternary? :
Assignment assignment = + = - = * = / =% = & = ^ = | = << = >> = >>> =
Let's look at an example of a union operator, and then realize that the game ... those who have learned C / C ++ are already aware of them. Still do not forget that, and whether I shared again. Those who did not read C / C ++. They please come to Java with basic idea.

Let's look at examples
class OperatorExample {
public static void main {String args []) {
int x = 10;
System.out.println (x ++); // 10 (11)
System.out.println (++ x); // 12
System.out.println (x -); // 12 (11)
System.out.println (--x); // 10
}
}

Output:

10
12
12
10

Nothing has been used only by the operators and I have printed. We got 10 x value. So let's first print 10. Since the print job is finished and the tune is the integration of the user in the unit, so the automatic one can be increased and x will be 11. But we did not prints printed x directly. So again because we have used the pre-anchorage means ++ x so the value of x is 11 to 12, then 12 will print. What do you mean? If the tune sign (x ++) is x, then the value of x will be increased after the end of a work. And before pre-increment, x will increase the value of x and then print it.

The decree will be the same and the same. First (x--) is printed. Since the tune increment will print before 12. Then the value of x will decrease 1. After decreasing because there is a pre-increment (--x), the value of x will decrease 1 again and 10 will print.

Those who still do not understand, please run the program on your computer. If you still do not understand, please refer to the above lines 10 times. But do not skip the request and do not skip. If you can understand later. Then it will never be understood. Because I'm a student too. After doing it later, it is not possible to find out that the semester ends.

If you see the example below, the unit operator will be more clearer.

class OperatorExample {
public static void main {String args []) {
int a = 10;
int b = 10;
System.out.println (a ++ +++ a); // 10 + 12 = 22
System.out.println (b ++ + b ++); // 10 + 11 = 21
}
}
This game is a little fun game. See what happened on the top ... There is nothing to fear. I am with you You also play I'm trying to explain ...

First of all, go to line number 5. I'm going to say that those who are new to them. Do not write the above line numbers but make mistakes. The netbin or eclips or notepad ++ code are also provided in the write window.

First we got a value of 10. Then see the number 5 on the tune increment. That means 1 after the work is done. But in the print line, after the increment, the Arithmetic Editing Operator + (plus) has been given. That means there was no need to print 10 before that. But since there is an EDITIV + operator, after going to the right side of the plus sign, it has become 11 increment 11. That means there are 10 on the left side. 11 is going to the right

On the right side, because the pre-increment has been a value of 11, now because pre-increment is already 1 will increase to 12. Then the value of ++ a right to 12

Now the left + right = 10 + 12 = 22

I hope you understand some of these two examples of the user operators

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 64867.61
ETH 3451.61
USDT 1.00
SBD 2.55