This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes long q = 2342347734; Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "long q = 2342347734;" Watch "long q = 2342347734;" New topic
Author

long q = 2342347734;

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

why do I get this error



The literal 2342347734 of type int is out of range


Jesus lives
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Because you try to assign an integer literal. Turn it into a long literal and you should be fine.

A long literal ALWAYS ends with a letter L (or a lowercase l, but that's too close to a 1 in many fonts so get used to always using an uppercase L to avoid confusion).


42
vignesh hariharan
Ranch Hand

Joined: Jun 23, 2005
Posts: 77
try this..

long q = 2342347734L;
long q = (long)2342347734; //sorry this results the same as previous
[ May 12, 2006: Message edited by: vignesh hariharan ]

Regards,
vignesh
Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

Oh I see, cheers
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by vignesh hariharan:
try this..
long q = (long)2342347734;


That has the same error as the original statement. Please test any suggestion before posting it.


There is no emoticon for what I am feeling!
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Jeroen T Wenting:
A long literal ALWAYS ends with a letter L (or a lowercase l, but that's too close to a 1 in many fonts so get used to always using an uppercase L to avoid confusion).


Projects that use CheckStyle often enforce the use of uppercase L for long literals with the UpperEll check


Tony Morris
Java Q&A (FAQ, Trivia)
 
 
subject: long q = 2342347734;
 
Similar Threads
Reading a char from int
Iterative Fibonacci Method Problem
WA #1.....word association
Up Arrow key press problem on IE
Recursion Problem