• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rory Lynch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Sherrif.

It's easy when you know the answer
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator



got it.
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • 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"!!)
 
Jinny Morris
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • 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: 9066
12
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Marilyn -

Thank you thank you! I just tried it and it works beautifully!
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic