2019年4月3日 星期三

第一個 JAVA 程式 Hello World

我的第一個 JAVA 程式
以下我們通過一個簡單的實例來展示 Java 程式設計,創建檔 Main.java(檔案名需與類名一致), 代碼如下:

實例
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("Hello World");
    }
}

利用online Java Compiler


Hello World


Java 程式利用 main 函數中 args 參數實現參數的傳遞(傳遞空格處理)

public class Main
{
    public static void main(String[] args)
    {
        System.out.println(args[0]);
        System.out.println(args[1]);
        System.out.println(args[2]);
    }
}

Command line arguments : aaa   bbb   ccc




aaa
bbb
ccc

沒有留言:

張貼留言

[Node-RED] 安裝

 [Node-RED] 安裝 源自於 https://blog.3dgowl.com/node-red-%E5%AE%89%E8%A3%9D/ [Node-RED] 安裝 因為 Node-RED 是由 Node.js 設計的物聯網(IoT) 視覺程式設計環境,所以安裝 Node-...