首页 > 试题广场 >

下边有一个Java小程序。其中有两段程序不见了。你的任务是找

[问答题]
下边有一个Java小程序。其中有两段程序不见了。你的任务是找出下面所列出的程序段与相符的输出。并非所有的输出都有可对应的程度段,且某些输出可能会被使用多次。画条线将相符的两者连接起来。
public class Mix4 {
  int counter = 0;
  public static void main(String [] agrs) {
    int count = 0;
    Mix4 [] m4a = new Mix4[20];
    int x = 0;
    while (                ) {       m4a[x] = new Mix4();       m4a[x].counter = m4a[x].counter + 1;       count = count + 1;       count = count + m4a[x].maybeNew(x);       x = x + 1;     }     System.out.println(count + " " + m4a[1].counter);   }   public int maybeNew(int index) {     if (                 ) {       Mix4 m4 = new Mix4();         m4.counter = m4.counter + 1;       return 1;     }     return 0;   } }

程序段:                 输出:
 A  x < 9                     1、14 7 
    index < 5                2、9 5                                                                                                                                                                                                                                     3、19 1
 B  x < 20                   4、14 1
    index < 5                5、25 1
                                  6、7 7
 C  x < 7                     7、20 1
    index < 7                8、20 5
                                
 D  x < 19
    index < 1




这道题你会答吗?花几分钟告诉大家答案吧!