JAVA SDK 7 http www oracle comtechnetworkjavasedownloadsindex html

  • Slides: 21
Download presentation

開發環境 • JAVA SDK 7 http: //www. oracle. com/technetwork/javase/downloads/index. html • Net. Beans 或

開發環境 • JAVA SDK 7 http: //www. oracle. com/technetwork/javase/downloads/index. html • Net. Beans 或 Eclipse Net. Beans https: //netbeans. org/downloads/index. html Eclipse http: //www. eclipse. org/downloads/

第一隻程式 • • • public class Welcome { public static void main(String agrs[]) {

第一隻程式 • • • public class Welcome { public static void main(String agrs[]) { System. out. println("Hello JAVA"); } }

print差別 • System. out. print("Hello JAVA"); • System. out. printf("Hello JAVA"); • System. out.

print差別 • System. out. print("Hello JAVA"); • System. out. printf("Hello JAVA"); • System. out. println("Hello JAVA");

資料型態 Primitive Types / simple type 範圍 中文 byte (1 byte) -128 ~ 127

資料型態 Primitive Types / simple type 範圍 中文 byte (1 byte) -128 ~ 127 位元組 short (2 bytes) -32768 ~ 32767 短整數 int (4 bytes) -2147483648 ~ 2147483647 整數 long (8 bytes) -9223372036854775808 ~ 9223372036854775807 長整數 float (4 bytes) +-3. 4028237*10+38~ +1. 30239846*10 -45 浮點數 double (8 bytes) +1. 76769313486231570*10 +3 08~ 倍準數 4. 94065645841246544*10 324 char (2 bytes) Unicode characters (含中文) 字元 boolean (1 bytes) true或false 布林函數 String 字串 字串

輸入資料 • Scanner input = new Scanner(System. in); • int a = input. next.

輸入資料 • Scanner input = new Scanner(System. in); • int a = input. next. Int(); • System. out. println(a);

正確應該是 • int a = 10; • int b = 3; • float c

正確應該是 • int a = 10; • int b = 3; • float c = (float)a/b;

猜猜看會顯示什麼 • • int a =123; if(a==1) System. out. print("1"); System. out. println("2");

猜猜看會顯示什麼 • • int a =123; if(a==1) System. out. print("1"); System. out. println("2");