I am getting null pointer exception when i am compiling my code

import java.util.*;

import java.io.*;

public class Main
{

static class FastReader
{

    BufferedReader br; 
    StringTokenizer st; 

    public FastReader() 
    { 
        br = new BufferedReader(new
                 InputStreamReader(System.in)); 
    } 

    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 

    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 

} 
public static void main (String args[]){
	FastReader s=new FastReader(); 
    int t = s.nextInt(); 
		while(t-->0){
			int n=s.nextInt();
			int []arr=new int[n];
			for(int i=0;i<arr.length;i++){
				arr[i]=s.nextInt();
			}
			int ans=fnosas(arr);
			System.out.println(ans);
		}
	}

	public static int fnosas(int []arr){
		HashMap<Integer,Integer> maps=new HashMap<Integer,Integer>();
		int[]prefix=new int[arr.length];
		prefix[0]=arr[0];
		for(int i=1;i<arr.length;i++){
			prefix[i]=prefix[i-1]+arr[i];
		}
	
		for(int i=0;i<prefix.length;i++){
			maps.put(prefix[i], maps.getOrDefault(prefix[i], 0) + 1);
		}

		int count=0;
		for(int key:maps.keySet()){
			int val=maps.get(key);
			if(val>1){
				count+=val*(val-1)/2;
			}
		}
		return count;
	}

}

@anshikapandey218
I will forward your doubt to the concerned person.

@anshikapandey218

Try this. The error has been removed. Try using this code. Extremely sorry for the delay.

But please tell me what’s the problem with that input method same method was followed on gfg as well for faster input as we know scanner is slow .

@anshikapandey218
I am not sure. I do not code in Java so its difficult for me to answer the question. Will get back to you shortly.