這個代碼怎么錯了?
public class HelloWorld{
? ? public static void main(String[] args) {
int a=16;
double b=9.5;
String str1="hello";
String str2="imooc";
System.out.println("a等于b:" + (a =(int) b));
為什么這個結(jié)果輸出是9
public class HelloWorld{
? ? public static void main(String[] args) {
int a=16;
double b=9.5;
String str1="hello";
String str2="imooc";
System.out.println("a等于b:" + (a =(int) b));
為什么這個結(jié)果輸出是9
2015-10-12
舉報
2015-10-12
b的值是9.5 類型強(qiáng)轉(zhuǎn)后取整,小數(shù)位丟棄 變成9