I'm interested in the order 'b' is calculated here:
int a = 3;
int b = a++ + (a-- * a++);
We've read in the lesson that the 1st priority belongs to parenthesis, so we begin with (a-- * a++), right? The 2nd priority is the unary operator, but which one? The lesson says it works from right to left. Does that mean I should first do the a++ in the parenthesis? When I increment it, do I use the incremented value in the 'a--' part, or do I save it just in case? Why is the output 15, not 16 then?
package en.codegym.task.pro.task08.task0817;
/*
Increments
*/
public class Solution {
public static void main(String[] args) {
int a = 3;
int b = a++ + (a-- * a++);
// b = (3+1) + ((3-1)*(3+1));
System.out.println(b);
//System.out.println(a);
}
}