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"
}
-
So what is exactly your question?Michael Rovinsky– Michael Rovinsky2021-04-30 06:00:28 +00:00Commented Apr 30, 2021 at 6:00
Add a comment
|
1 Answer
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()
}
1 Comment
user3703276
thank you so much was stuck on the problem for about an hour