I found that the above did not work for me. I was pulling a cell value from a JTable but could not cast to double or int etc. My solution:
Object obj = getTable().getValueAt(row, 0);
where row 0 would always be a number. Hope this helps anyone still scrolling!