This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes long a = 0x1234ffffaaaabbbb ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "long a = 0x1234ffffaaaabbbb ??" Watch "long a = 0x1234ffffaaaabbbb ??" New topic

long a = 0x1234ffffaaaabbbb ??

Pin Ting

Joined: May 28, 2003
Posts: 22
The primitive type long occupies 64 bits in Java, then why this statement doesn't compile
long a = 0x1234ffffaaaabbbb;
thanks all

Never do things the hard way if you don't have a good reason.
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

It doesn't compile because the compiler thinks that the value is an int. You have to say:
long a = 0x1234ffffaaaabbbbL;
to force the compiler to recognize it as a long.
[ May 30, 2003: Message edited by: Joel McNary ]

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Pin Ting

Joined: May 28, 2003
Posts: 22
Thanks a lot, Joel.
I agree. Here's the link:
subject: long a = 0x1234ffffaaaabbbb ??
It's not a secret anymore!