JAVA 프로그래밍

문제

제네릭 클래스 ArrayList 및 Collections를 바탕으로 점수 및 단어를 정렬하는 문제입니다 이를 해결하는 프로그램의 다음 실행상태에 대해 빈칸을 채우세요 

프로그램의 실행순서 및 실행상태

1  public static void main( String[] args ) {  

2   Collections.sort( scores );
              main()
scores
     [0]         [1]         [2]    (obj01)
 
  (obj02)   (obj03)   (obj04)
    90       89       86  

3   System.out.println();
86 89 90
              main()
scores  (obj01) 
     [0]         [1]         [2]    (obj01)
 
  (obj02)   (obj03)   (obj04)
    90       89       86  

4   Collections.sort( words );
              main()
scores  (obj01) 
 words
     [0]         [1]         [2]    (obj01)
  (obj04) (obj03) (obj02)
  (obj02)   (obj03)   (obj04)
    90       89       86  
     [0]         [1]         [2]    (obj05)
 
  (obj06)   (obj07)   (obj08)
  'carrot'   'banana'   'apple'

apple banana carrot

5  }
              main()
scores  (obj01) 
 words  (obj05) 
     [0]         [1]         [2]    (obj01)
  (obj04) (obj03) (obj02)
  (obj02)   (obj03)   (obj04)
    90       89       86  
     [0]         [1]         [2]    (obj05)
 
  (obj06)   (obj07)   (obj08)
  'carrot'   'banana'   'apple'


프로그램 코드

	import java.util.*;
	
	public class GenericTest {
1		public static void main( String[] args ) { 	
			ArrayList<Integer> scores = new ArrayList<>();
			scores.add( 90 );
			scores.add( 89 );
			scores.add( 86 );
2			Collections.sort( scores );
			for( int i = 0; i < scores.size(); i++ )
			    System.out.print( scores.get(i) + " "  );
3			System.out.println();
			
			ArrayList<String> words = new ArrayList<>();
			words.add( "carrot" );
			words.add( "banana" );
			words.add( "apple" );
4			Collections.sort( words );
			for( int i = 0; i < words.size(); i++ )
			    System.out.print( words.get(i) + " "  );
	
5		}
	}