I'm new to the coding can anyone explain to me why below code is giving output as '6'
class Test{
public static void main(String[] args) {
int i = 5;
i = i++;
i = ++i;
System.out.print(i);
}
}
I'm new to the coding can anyone explain to me why below code is giving output as '6'
class Test{
public static void main(String[] args) {
int i = 5;
i = i++;
i = ++i;
System.out.print(i);
}
}
i = i++; This line assign 5 to i again you can run this code to ensure about that:
class Test{
public static void main(String[] args) {
int i = 5;
i = i++;
System.out.println(i);
i = ++i;
System.out.println(i);
}
}
For more information visit here