I want to convert the cell value into int value so i am trying following code:
for (int chk1 = 1; chk1 < m; chk1++ ) {
int intCounter = Integer.parseInt( cells.checkCell(chk1,0).getValue().toString() );
}
But it is accepting only the string format if there is any number then it is giving me
java.lang.NumberFormatException
How can I avoid this? Is there any way to convert all data into integer or into String or vice versa?
The problem is the “.0” bit.
Integer.parseIntonly allows digits so the decimal point is illegal, hence theNumberFormatException.You should make sure that your input really is an integer (i.e. “16”), or if you actually want to allow decimals then use
Double.parseDoubleorFloat.parseFloat.