Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Declare a Long value

 
Frank Daly
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I'm attempting to store a long value in a variable using the code
long hope = 991909000000
However because this value is greater thant the maximum for an integer I get the error integer number too large

The funny thing is I can delare the variable to be = System.currentTimeMillis()
which is greater than the max integer value

I'm using the J2ME Wireless Toolkit version 2.2

Am I missing something?

Frank
 
Paul Clapham
Sheriff
Posts: 21955
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual way to declare a long literal in Java isNote the "L" at the end.
 
Frank Daly
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks Paul.

Frank
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!