Input and output of common numbering (JAVA)

Source: Internet
Author: User

/* * 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.