開始使用免費開始

再看諾貝爾獎得主

還記得上一題提到的諾貝爾物理學獎得主嗎?你決定更偏好 Heisenberg 而非 Fermi,因此想更新你的紀錄。

本練習屬於課程

Java 入門

檢視課程

練習說明

  • nobelLaureates 的第三個元素改為 "Heisenberg"
  • years 的第三個元素改為 1932
  • 完成印出敘述,印出兩個陣列的最後一個元素。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

class NobelForPhysicsLaureatesRevisited {
    public static void main(String[] args) {
    
        String[] nobelLaureates = {"Curie", "Einstein", "Fermi"};
        int[] years = {1903, 1921, 1938};
        
        // Replace Fermi with Heisenberg
        ____[____] = "Heisenberg";
        // Correct the year
        years[____] = ____;
        
        System.out.println(nobelLaureates[0] + " won in " + years[0]);
        System.out.println(nobelLaureates[1] + " won in " + years[1]);
        // Print the last record
        System.out.println(nobelLaureates[____] + " won in " + ____[____]);
    }
}   	
編輯並執行程式碼