MulaiMulai sekarang secara gratis

Nobel winners revisited

Remember the Nobel Prize laureates for Physics from the last exercise? You decide to prefer Heisenberg to Fermi, so you want to update your records.

Latihan ini adalah bagian dari kursus

Introduction to Java

Lihat Kursus

Petunjuk latihan

  • Change the third element of nobelLaureates to "Heisenberg".
  • Change the third element of years to 1932.
  • Finish the print statement to print the last element of both arrays.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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 " + ____[____]);
    }
}   	
Edit dan Jalankan Kode