Java基礎系列—-4、Java基礎文法

來源:互聯網
上載者:User

標識符:
由字母、數字、_、$組成,數字不可以開頭。
Java嚴格區分大小寫。

Java中的名稱規範:
· 包名:xxxyyyzzz
· 類名介面名:XxxYyyZzz
· 變數名函數名:xxxYyyZzz
· 常量名:XXX_YYY_ZZZ

  位元組數 位元 範圍 備忘
byte 1 8 -128~127  (-2^7 ~ 2^7-1)  
short 2 16 -32768~32767   (-2^15 ~ 2^15-1)  
int 4 32 -2147483648~2147483647   (-2^31 ~  2^31-1)  
long 8 64 -9223372036854774808~9223372036854774807  (-2^63 ~ 2^63-1)  
         
char 2 16 字元的儲存範圍在\u0000~\uFFFF char a='你';√

例子:不使用第三方變數交換兩個變數的值。

原理:利用異或
n=3,m=8
n=n^m;
m=n^m;//(n^m)^m
n=n^m;//n^(n^m)

例子:九九乘法表

for (int x=1;x<=9;x++){for(int y=1;y<=x;y++){System.out.print(y+"*"+x+"="+y*x+"\t");}System.out.println();}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.