This week's book giveaway is in the Testing forum.We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

Missing Numeric Suffixes

Joshua Smith
Ranch Hand
Posts: 193
Why aren't there numeric suffices for byte, short or int? By numeric suffices I mean the letters that you attach to a number to coerce it into being a specific type of primitive literal (e.g. 2L to mean "2 as a long"). The lack of a numeric suffix for int kind of make sense as int is the default for integral numbers, but then consistency would seem to indicate that there wouldn't be one for double since double is the default for floating point literals. And why would byte and short be left out?

I'm not sure how important the answer to this question is to certification, but I'm wondering if there's something about the numeric primitives that I'm missing that would make the answer obvious.

Thanks,
Josh

Thomas Paul Bigbee
Ranch Hand
Posts: 71
Its because floating point literals (0.1, 122.32, etc...) are automatically considered as doubles, so float x = 0.1 would cause a compile time error, where as with bytes, shorts, chars, ints and longs, this would work with all of them - byte x = 1, short x = 1, etc..., its just the way the spec was written.