0
++5 & 5++ java answer?
++5 & 5++ java answer?
5 Respostas
+ 5
++5 & 5++ java question?
Ask a complete and clear question in order to get a complete and clear answer.
+ 4
You ask post increment and pre increment operator if you have done this topic then practice on sololearn playground otherwise do that topic.
+ 3
This question is popular in the programming world. Personally, I think if you're a slow learner, you need a lot of test cases to understand how both of these statement works but for the discuss sake, I'll be giving you some explanation
++5 will return 6 to where it is called while 5++ will return 5 to where it is called. To explain this better
int x = 5;
int y = 5;
int a = ++x;
At this point, a is 6 and x is also 6
int b = y++;
at this point, b is 5 and y is 5. But subsequent call to y will be 6
cout << y // 6
cout << b // 5
cout << a // 6
cout << x // 6
You really need many examples to understand this weird incrementation behavior. Knowing it dearly is like knowing 20% of programming
+ 2
error will occur
System.out.print(++5); //error
int x = 0
//pre-increment
System.out.print(++x); //1
System.out.print(x); //1
---------
System.out.print(5++); //error
int y = 0
//post-increment
System.out.print(y++); //0
System.out.print(y); //1
+ 1
int a=5, b=5;
System.out.println( ++a & b++ ); // 4
++a is 6
a & b is 4 because binary:
110 6
& 101 5
-------
100 4
++ at the end is irrelevant for expression,
but b is 6 then