How to properly assign text file values to array in java
I need help properly assigning the values that I fetch from the text file into the array. And then loop through it. Here's my current code,
my problem is that the buffered reader fetches null values. And when I run the program , I get index out of bounds error and null pointer exception
public class Main {
public static String[] q=new String[50];
public static String[] a=new String[50];
public static String[] b=new String[50];
public static String[] c=new String[50];
public static String[] d=new String[50];
public static char[] ans=new char[50];
public static Scanner x=new Scanner(System.in);
public static int random(int min, int max){
int xx;
xx= (int) ( Math.random() * (max-min + 1))+ min;
return xx;
}
public static void main(String[] args) {
int ii=0;
int score=0;
try {
FileReader fr;
fr = new FileReader (new File("F:\\qa.txt"));
BufferedReader br = new BufferedReader (fr);
while (br.readLine()!= null) {
for(int ox=0;ox<5;ox++){
q[ox]= new String();
a[ox]= new String();
b[ox]= new String();
c[ox]= new String();
d[ox]= new String();
Bookmarks