LoslegenKostenlos loslegen

All the winners

When working with collections of data, you often need to know how many items you're dealing with. Arrays provide a simple way to check their size, which is essential for processing, validation, and reporting. Let's measure your collection of Nobel laureates!

Diese Übung ist Teil des Kurses

Introduction to Java

Kurs anzeigen

Anleitung zur Übung

  • Print the length of literatureLaureates and chemistryLaureates arrays.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

class AllNobelLaureates {
    public static void main(String[] args) {
    
        String[] physicsLaureates = {"Curie", "Einstein", "Fermi"};        
        String[] literatureLaureates = {"Kipling", "Shaw", "Hemingway", "Seifert"};
        String[] chemistryLaureates = {"Curie", "Heyrovsky"};

		// Print the lengths of the arrays
        System.out.println(physicsLaureates.length + " physics laureates");
        System.out.println(literatureLaureates.____ + " literature laureates");
        System.out.println(____ + " chemistry laureates");
    }
}   	
Code bearbeiten und ausführen