I will probably go with the right datatype for right operations , long
if I need long
, int
if int
is enough for my requirements . Common sense would be to think using long
for int
probably will slow you down in general, but again this depends on the specific JVM implementation. You will have to decide based on the range which you want to target .
Again , if there are lots of casting involved in your program , then better to go for a datatype like long
which can accommodate a larger range than int
and save you from casts and loss of data in that process . Having said that , long
might be slower than int
although in modern processors and JVMs I doubt that might affect much .
May be , enlightened ones here can answer this question better.