-1
if (aa.isNullOrBlank() || aa.isEmpty() || aa.isNullOrEmpty()) {//to check null
} else {
    someVar = aa.toInt()
    //here error is showing java.lang.NumberFormatException: For input string: "null"
}
1
  • So what is exactly your question? Commented Apr 30, 2021 at 6:00

1 Answer 1

2

Before casting into Integer, you have to check if there are only digits. By isDigitsOnly()

if (aa.isNullOrBlank() || 
    aa.isEmpty() || 
    aa.isNullOrEmpty() ||  
    !aa.isDigitsOnly() ||
    aa.toIntOrNull() == null
) {
//to check null
} else {
    arra[i][j] = aa.toInt()
}
    
Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much was stuck on the problem for about an hour

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.