Answer the question
In order to leave comments, you need to log in
Incomprehensible display of the results of several successive in(de)crementations?
class temp{
public static void main(String args[]){
int t = 011;
System.out.println(t); //9
System.out.println(t++); //выводится на экран 9, почему не 10?
System.out.println(t++); //10
System.out.println(t++); //11
}
}
9
10
11
12
9
9
10
11
Answer the question
In order to leave comments, you need to log in
A post-increment (i++) differs from a pre-increment in that it returns the value it had before the increment, changing the value of the variable itself. This is clearly seen in the C++ example . The semantics in the languages is the same.
To convert to octal, you can use the Integer.toOctalString(int) method;
There is already a correct answer, so I'll just give advice :).
Avoid using unary operators in expressions and function calls. Compilers are good at optimizing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question