java基礎學習 視頻學習 資料類型以及運算子

來源:互聯網
上載者:User
 

 

若干DOS命令

d:

cd

cd..

cd/

md

rd

del

exit

start

echo content >/>> filename.txt

SUN Stanford University Network

跨平台性

Java虛擬機器

JVM Java Virtual Machine

JRE Java Runtime Environment Java運行環境

JDK Java Development Kit Java開發套件

編譯工具javac.exe

打包工具jar.exe

Dos中設定臨時變數

Set path=

Set classpath=

 查看

Set path

Set classpath

 \n:換行

\b:退格

\r:按下斷行符號鍵。window系統中,斷行符號符是有兩個字元來表示“\r\n”

\t:定位字元

 

byte:位元組,佔8位(bit)二進位,能表示的最大數字為2的8次方,含正負,故範圍為: -128...0...127

char:單字元型。由於java統一使用unicode編碼來表示一個字元;unicode佔2個位元組(16位)。

char可以表示任一字元,含半形字母數字等,也可以表示中文。

如 char c1 = 'A';

  char c2 = '1';

  char c3 = '我';

由於半形字元比較特殊,來源於8位(1byte)Ascii碼,也就是說1個位元組就足夠儲存。在unicode中使用低8位(1byte)就可以表示,高8位不使用也無所謂。儲存到記憶體中就只佔一個位元組。

而中文就使用完整的16位unicode,儲存到記憶體中就佔2個位元組。

 

java的String其實就是char[]的封裝類型

 

 

short a = 4;/* 自動轉化 */a += 5;/* * short+int ->int=int + int -> short= (short)int 最後強制轉化 */a = (short) (a + 5);

 

/* 邏輯運算子中&和 &&以及 !!與!的聯絡與區別 &&:短路與 ||:短路或 */public class Main {public static void main(String[] args) {/* * &和&&的特點: &:無論左邊是真是假,右邊都運算 &&:當左邊為假時,右邊不運算 */int a = 2, b = 4, c = 8;if (a < 2 && (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a < 2 & (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);/* * |和||的特點: |:兩邊都參與運算 ||:當左邊為真時,右邊不參與運算 */a = 2;b = 4;c = 8;if (a == 2 || (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a == 2 | (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);}}/*4 1032324 10 */

 

/* 邏輯運算子中&和 &&以及 !!與!的聯絡與區別 &&:短路與 ||:短路或 */public class Main {public static void main(String[] args) {/* *  * &和&&的特點: &:無論左邊是真是假,右邊都運算 &&:當左邊為假時,右邊不運算 */int a = 2, b = 4, c = 8;if (a < 2 && (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a < 2 & (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);a = 2;b = 4;c = 8;if (a == 2 && (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a == 2 & (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);/* * |和||的特點: |:兩邊都參與運算 ||:當左邊為真時,右邊不參與運算 */a = 2;b = 4;c = 8;if (a == 2 || (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a == 2 | (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);a = 2;b = 4;c = 8;if (a > 2 || (b = 12) > 13) {System.out.println(Integer.SIZE);}if (a > 2 | (c = 10) > 13) {System.out.println(Integer.SIZE);}System.out.println(b + " " + c);}}/*4 1012 1032324 1012 10 */

 java輸入輸出重新導向

方法一:

javac Main.java

java Main <data.in >data.out

方法二:

javac Main.java

javac Data.java

java Data | java Main >data.out

上句其實是

java Data >data.in

java Main <data.in >data.out

Data的標準輸出資料流和Main的標準輸入資料流是相同的流。

 double num=0.1;

num+num==0.2 true

num+num+num==0.3 false

 

 

聯繫我們

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