/* * 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;//octal number byte a2=10;//decimal Number byte a3=0x21;//Hexadecimal number 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) + "(octal output)") system.out.print ("\ta1=" + A1);//Decimal Output system.out.print ("\ta2=" +A2); system.out.print ("\ta3=0x" +integer.tohexstring (A3) + "(by hexadecimal output)"); system.out.println ("\ta3=" +a3);//output by decimal system.out.print ("i1=" +integer.tobinarystring (I1) + "(binary output)"); system.out.print ("\ti1=" +i1); System.out.print ("\tb1=" +b1); &Nbsp; 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 results
run:sum=6a1=071 (octal output) a1=57 a2=10 a3=0x21 (in hexadecimal output) a3=33i1=100 (binary output) i1=4 b1=15 b2=15c1=0x1e2 c1=482 d=4335 d1=1234567 successfully built (total time: 1 seconds)
This article is from the "Sanghaidan blog column" blog, please be sure to keep this source http://10602803.blog.51cto.com/10592803/1683049
Input and output of common numbering (JAVA)