我需要将输入测试用例从控制台读入二维数组和一维数组,但无法在我的代码中找到错误
import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public static final int SIZE = 5;
public static int card[][];
public static int ball[];
public static void read()throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int count=0;
for(int row = 0; row < SIZE && count < 25; row++){
String line= br.readLine();
System.out.println("line"+line);
//if((line= br.readLine()) != null) {
int column = 0;
StringTokenizer st = new StringTokenizer(line);
while(st.hasMoreTokens()){
card[row][column] = Integer.parseInt(st.nextToken());
column++;
count++;
}
column = 0;
// }
}
int i = 0, b=0;
String line ;
while((line =br.readLine() )!= null && i < 75) {
StringTokenizer st1 = new StringTokenizer(line);
while(st1.hasMoreTokens()){
ball[i++]= Integer.parseInt(st1.nextToken());
}
}
}
public static void printing() {
System.out.println("Card values\n");
for(int i=0;i<SIZE;i++) {
for(int j=0;j<SIZE;j++){
System.out.print(card[i][j]+"\t");
}
System.out.println();
}
System.out.println("Ball values\n");
for(int j=0;j<75;j++) {
System.out.print(ball[j]+"\t");
//System.out.println();
}
}
public static void main (String[] args) throws java.lang.Exception
{
card = new int[SIZE][SIZE];
ball = new int[75];
for(int t=0 ; t<2 ; t++) {
read();
printing();
}
}
}
测试用例输入如下
10 17 44 59 62
2 28 31 58 68
5 16 37 53 71
6 26 35 51 66
9 21 34 60 70
45 37 19 47 16 39 66 14 28 15
72 17 62 12 55 11 73 75 9 18
56 4 29 32 61 63 51 38 33 2
8 36 6 24 23 22 21 5 60 35
41 74 34 7 67 25 50 10 43 53
3 46 68 40 48 69 54 30 20 70
31 59 57 49 1 42 58 27 52 13
64 44 71 26 65
1 7 4 9 2
2 28 31 58 68
5 16 37 53 71
6 26 35 51 66
9 21 34 60 70
45 37 19 47 16 39 66 14 28 15
72 17 62 12 55 11 73 75 9 18
56 4 29 32 61 63 51 38 33 2
8 36 6 24 23 22 21 5 60 35
41 74 34 7 67 25 50 10 43 53
3 46 68 40 48 69 54 30 20 70
31 59 57 49 1 42 58 27 52 13
64 44 71 26 65
我能够阅读第一个测试用例,但是在阅读第二个测试用例时,我收到了 null 错误。