为什么同样的code两种技术的不同表现 [英] why same code in two technology behaving different
本文介绍了为什么同样的code两种技术的不同表现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是在C我的code片段。
Below is my code snippet in C.
void main(){
int x = 7;
x = x++;
printf("%d",x);
}
输出:8
public static void main(String[] args){
int x = 7;
x = x++;
System.out.println(x);
}
输出:7
我没有得到为什么这两个语言给不同的输出。
我已经提到以下链接
什么是X后英寸×= X ++"?
i am not getting why both language giving different output. I've referred below link What is x after "x = x++"?
推荐答案
在Java的十大之后++中有值没有变化 X
In java after x++ there is no change in the value of x
X = X ++;等于
x = x++; equal to
int i= x;
x = x + 1;
x = i;
所以 X
保持相同的 I 的
您可以阅读从这里更多:<一href=\"http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc\">Could谁能解释这些不确定的行为,(I = I + + + + I,I = I + +,等...)
You can read more from here :Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc...)
这篇关于为什么同样的code两种技术的不同表现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文