int a = 5;
int b, c;
b = a++;
c = ++a;
About this code b has a value 5 because posting fix increment/decrement happens after assingment is completed. So the value is 5.
c has a value 7 because prefix increment/decrement happens before assingment is completed. So the value is 7 beause previous statement made the value of a as 6.
About this code
int a = 5;
int b;
b = (a++) - (++a);
System.out.println("B = " +b);
when brackets are applied, your prefix/postfix operations will be completed first in (a++) - (++a);
from left to right fashion.
So firstly if we go left to right
(a++) -(++a)
1. (a++) -- Take 5 from a.
2. (++a) -- 5 becomes 6 with ++a take 6.
3. (a++) - (++a) -- Subtract results of (a++) - (++a) operations which makes it -2.
Solutions for you first query -- How can I have it not take the value of 'a' from 'b', and
int a = 5;
int temp = a;
int b, c;
b = a++;
c = ++temp;
System.out.println("B = " +b);
System.out.println("C = " +c);
**Solutions for you first query has been well explained by Sir @Keppil **