首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

int门类定义

2012-08-21 
int类型定义public class TestInt {??? public static void main(String[] args) {??? ??? int a 0130?

int类型定义

public class TestInt {

??? public static void main(String[] args) {
??? ??? int a = 0130;???? //前面加0,代表这个常量是以8进制格式声明的
??? ??? System.err.println(a);?? //输出88?? 八进制转十进制算法:0*8^3(8的3次方) + 1*8^2 + 3*8^1 + 0*8^0
??? ???
//??? ??? int a2 = 08;?? //错 8进制数里面没有8和9这2个数字
//??? ??? int a22 = 0193;? //错 8进制数里面没有8和9这2个数字
??? ??? int a3 = 8;
??? ??? int a4 = 0x80;
??? ???
??? ???
??? ??? String str = "0130";
??? ??? int strInt = Integer.parseInt(str);
??? ??? System.err.println("strInt=" + strInt);? //输出130
??? ???
??? }

}

热点排行