• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Why wont this line compile? (Assignment Java 4b)

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I am working on my second attempt at Java 4b Say.
I had introduced a confusing piece of code..

else if ( (n < 0) || ( ( n / 1000000) > 999999 ) )

and it was nitpicked

so I attempted..
long upperLimit = 999999999999;
I was then going to use upperLimit in the condition, but the above line wont compile!

Any clue as to why not?

thanks
Rory
 
lowercase baba
Posts: 12974
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as a general note, when you post "this won't compile", it is a trememdous help if you post the compiler error. It really, truly does tell you what the problem is, or gives you a pretty good hint.
 
Rory Lynch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point.
the error is as follows

*>javac Say.java
Say.java:81: integer too large: 999999999999
long upperLimit = 999999999999;
^
1 error

NB. the hat symbol is below the fist 9, but the formatting is lost on posting

I am confused because I am attemping to declare and initialize a long and not an integer.
[ August 31, 2007: Message edited by: Rory Lynch ]
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want it to be recognized as a long, you'll need to append an "L", as in "999999999999L", otherwise the compiler assumes you want an int.
 
Rory Lynch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sherrif.

It's easy when you know the answer
 
Sheriff
Posts: 9103
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[I]Originally posted by Rory Lynch:
the error is as follows


NB. the hat symbol is below the fist 9, but the formatting is lost on posting
[/I]

The key when you want to maintain the formatting is to put it into code tags (note the buttons below the text area when you post)
 
Rory Lynch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



got it.
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rory,

You crack me up!

(When you write "fingers crossed" at the end of your assignments, an evil part of me wants to retort "Mwhaa haa haaa... don't hold your breath"!!)
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marilyn wrote:

The key when you want to maintain the formatting is to put it into code tags (note the buttons below the text area when you post)



The only way I know to capture the console error messages is to redirect the error file output - but the resulting text file doesn't have the carats in the "right" places either ... is there a better way?
 
Marilyn de Queiroz
Sheriff
Posts: 9103
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To copy from a DOS prompt, you can use the little icon at the top left of the command prompt window to good advantage. Click on it and choose properties ...
In the options tab, put a check in the Edit Options QuickEditMode checkbox.
In the layout tab, you can change the size of the screen.

Now when you run your app, you can highlight the output by dragging the mouse and copy it by pressing "enter" (not Ctrl-C). You can paste by putting the mouse pointer inside the edit screen (anywhere) and click the right mouse button.

If you want to skip the first steps, you can use the little icon and choose "Mark", "Copy", and "Paste"
 
Jinny Morris
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marilyn -

Thank you thank you! I just tried it and it works beautifully!
 
Marilyn de Queiroz
Sheriff
Posts: 9103
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
My cellmate was this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic