I couldn't find any information about this when searching StackOverflow or Google, and I've got some coworkers who disagree with my preference for how to initialize a simple Long
variable.
Is there any reason to use one of these formats over the other?
Long foo = (long) 0; // First way of doing it
Long bar = 0L; // Second way of doing it
I'm most interested if anyone knows if there is an efficiency difference here.
The reason I prefer the second way is because you can specify values less than Integer.MIN_VALUE
and greater than Integer.MAX_VALUE
, whereas Eclipse would complain with something along the lines of "The literal 10000000000 of type int is out of range" if you used the first way here.