시작하기무료로 시작하기

모든 수상자

데이터 모음을 다룰 때는 항목이 몇 개인지 파악해야 할 때가 자주 있어요. 배열은 크기를 확인하는 간단한 방법을 제공하므로 처리, 검증, 보고에 필수적이에요. 노벨상 수상자 목록의 크기를 확인해 볼까요?

이 연습은 강의의 일부입니다

Java 소개

강의 보기

연습 안내

  • literatureLaureateschemistryLaureates 배열의 길이를 출력하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

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");
    }
}   	
코드 편집 및 실행