0
What does --X mean (the X part)
5 Respostas
+ 2
--X means reduce X in one unit and then get its value.
So, Y=--X is equivalent to
X-=X;
Y=X;
0
So basically it would be like
--X would be one if X =2?
0
Yes, but not only that. It would give back the value 1, so if X=2, System.out.println(Integer.toString(--X)); would print "1".
On the other hand, if you write X--, first you get back the value of X and then then decrements it by one, so if X=2, System.out.println(X--) would print 2.
Integer.toString converts an integer value into a string. It is done automatically if you don't write so.