/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/package c2_1;/**
*
* @author pc
*/public class C2_1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) { byte a1=0071;//八进制数
byte a2=10;//十进制数
byte a3=0x21;//十六进制数
int b1,b2,i1=4; short c1=0x1e2; long d=0x10ef,d1=1234567;
b1=b2=15;
System.out.println("sum="+(1+5));
System.out.print("a1=0"+Integer.toOctalString(a1)+"(八进制输出)");
System.out.print("\ta1="+a1);//按十进制输出
System.out.print("\ta2="+a2);
System.out.print("\ta3=0x"+Integer.toHexString(a3)+"(按十六进制输出)");
System.out.println("\ta3="+a3);//按十进制输出
System.out.print("i1="+Integer.toBinaryString(i1)+"(二进制输出)");
System.out.print("\ti1="+i1);
System.out.print("\tb1="+b1);
System.out.print("\tb2="+b2);
System.out.format("c1=0x"+"%x",c1);
System.out.print("\tc1="+c1);
System.out.print("\td="+d);
System.out.print("\td1="+d1);
}
}运行结果
run:sum=6a1=071(八进制输出) a1=57 a2=10 a3=0x21(按十六进制输出) a3=33i1=100(二进制输出) i1=4 b1=15 b2=15c1=0x1e2 c1=482 d=4335 d1=1234567成功构建 (总时间: 1 秒)
本文出自 “桑海田 博客专栏” 博客,请务必保留此出处http://10602803.blog.51cto.com/10592803/1683049
原文:http://10602803.blog.51cto.com/10592803/1683049