java練習---6

來源:互聯網
上載者:User

標籤:計算   class   精度   ext   value   bool   字元   rgs   溢出   

 1 //程式員:羅元昊  2017.9.24 2 import java.util.Scanner; 3 public class L { 4  5     public static void main(String[] args) { 6         long a ;                //練習題1:輸出一個長整型的變數 123456789012345 7         a=123456789012345l; 8         System.out.println(a); 9         10         float b=2.4f;            //練習題2:輸出一個單精確度的小數常量 2.411         System.out.println(b);12           13         boolean c=true;            //練習題3:輸出一個布爾類型的變數14         System.out.println(c);15         c=false;16         System.out.println(c);    17            18         byte d=3;                //練習題4:強制類型轉換19         d=(byte)(b+200);20         System.out.println(d);    21              22         System.out.println((char)(‘a‘+1));//練習題5:輸出1個字元型的加法計算23         System.out.println((char)(‘你‘+1));24                 25         int e=Integer.MAX_VALUE+1;        //練習題6:int 也對應著一個類,Integer 示範變數的溢出效果26         System.out.println(e);27                 28         @SuppressWarnings("resource")      //練習題7:算術運算子+-*/29         Scanner input=new Scanner(System.in);30         double f;31         System.out.println("Enter the x ");32         f = Double.valueOf(input.nextDouble());33         f=f/1000*1000;34         System.out.println("The calculation result is " + f);35         }36 37 }

 

java練習---6

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.