```java public class ExampleMethod { /* * public : 宣告這是一個公開的方法,只要在同個專案內就可以呼叫。 * * static : 在 Java 中將方法或變數聲明為 static 時, * 它們將在程式執行時就載入記憶體,不需要特別實例化物件才能呼叫。 * * void : 宣告這個方法並不需要回傳值。 * * test1 : 宣告這個方法的名字。 */ public static void test1() { } /* * 同上,這是個 static 方法,但這個方法設定可以傳入參數。 * 也因為有多傳入參數設定,所以 test1 這個名稱還是可以用。 * 如果沒有設定傳入參數的話,同樣的名稱無法用。 * 這就是 Java 中的多載(overloading)。 */ public static void test1(String param) { } /* * private : 宣告這是一個私有的方法,在不同類別就無法呼叫。 * * String : 宣告這個方法需要回傳字串。 * * test2 : 宣告這個方法的名字。 * * 也因為這個沒有宣告 static,若要呼叫這個方法,則得需要實例化該類別才能使用。 */ private String test2() { return ""; } /* * 再做一個多載的方法當作實際的範例 */ private String test2(String param) { return ""; } public static void main(String[] args) { String str = "input something"; //這邊因為是 static method 可以直接呼叫方法 test1(); test1(str); //這邊不是 static method,所以需要實例化類別後才可以呼叫方法 ExampleMethod testClass = new ExampleMethod(); testClass.test2(); testClass.test2(str); } } ```