1 / 11

Java 基礎概念

Java 基礎概念. 2014/6/23. 位元碼. Java 的編譯與執行的程序 : 將程式碼編譯成與平台無關( platform-independent )的機器碼,稱之為「位元碼」( byte-codes ) 經編譯後,可在裝有 JVM 上的平台直接執行 下圖說明 Java 相關的執行流程:. 位元碼. 最大的好處是 -- 可跨越平台來執行:. 類別. Java 程式是由類別 ( class ) 所組成 下面的程式片段即為定義類別的 範例 public 指的是對於類別的存取方式為 共有 在 完整的 Java 程式裡,至少需要有一個 類別.

levana
Download Presentation

Java 基礎概念

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java基礎概念 2014/6/23

  2. 位元碼 • Java的編譯與執行的程序: • 將程式碼編譯成與平台無關(platform-independent)的機器碼,稱之為「位元碼」(byte-codes) • 經編譯後,可在裝有JVM上的平台直接執行 • 下圖說明Java相關的執行流程:

  3. 位元碼 • 最大的好處是--可跨越平台來執行:

  4. 類別 • Java程式是由類別(class)所組成 • 下面的程式片段即為定義類別的範例 • public指的是對於類別的存取方式為共有 • 在完整的Java程式裡,至少需要有一個類別

  5. 程式執行的起始點 • 每一個Java程式必須有一個main() method,而且只能有一個 • main() method之前必須冠上修飾子:public static void

  6. 練習 • 撰寫程式 • 主程式內容為空 • 可執行,但執行結果為空。

  7. 輸出 • 使用println() 印出變數與字串:

  8. 練習 • 撰寫程式輸出資料 • 輸出自己的班級、學號、姓名

  9. 利用cmd執行Java • (1) 用記事本編輯程式app1_1 (2) 存入C:\Java資料夾 (3) 鍵入檔名app1_1.java • (4) 存檔類型請選擇「所有檔案」

  10. 利用cmd執行Java

  11. 練習 • 利用cmd來執行Java程式 • 移動資料夾:cd 資料夾名稱 • 回上層資料夾:cd ..

More Related