tags:

views:

28

answers:

1

I have a JTable used to store numbers. I really only use the table for viewing/sorting. Is there a downfall (other than maybe needed to allocate more space) to giving the columns a class of Double even if some of the columns may have all ints or longs. I can parse the numbers to see if a column contains all of a single type, but that seems like a lot of work if I don't really need to.

thanks, Jeff

+2  A: 

I'm assuming that you're writing your own TableModel, and overriding the getColumnClass() method. And furthermore, that you want the table to pick a renderer that right-justifies numbers, but don't otherwise care about rendering differences.

If that's the case, then I'd suggest returning Number.class, and not particularly bothering with storing the actual model data as Double.

kdgregory