I was solving aquestion on CodeChef platform when I faced a NumberFormatException.
First I used Scanner for handling the inputs, then BufferedReader. But none of them worked!
Here is my code:
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; class Practise { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t > 0) { String s = br.readLine(); ArrayList<String> al = new ArrayList<>(); int i = 0; while(i < s.length()) { String temp = ""; while(s.charAt(i) != ' '){ temp += s.charAt(i); i++; if(i >= s.length()) { break; } } al.add(temp); i++; } if(al.contains("not")) { System.out.println("Real Fancy"); } else { System.out.println("regularly Fancy"); } t--; } } } What could the problem be?
Input -->The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. -->The first and only line of each test case contains a single string S denoting a quote.
The Exception message i am getting-
Exception in thread "main" java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:542) at java.lang.Integer.parseInt(Integer.java:615) at Practise.main(Main.java:11)
int t=Integer.parseInt(br.readLine());make sure the value ofbr.readLine()is pure numberbr.readLine()value, then probably you'll see that is not a just a number.