aspose file tools
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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 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.
Consider Paul's rocket mass heater.
subject: long a = 0x1234ffffaaaabbbb ??