File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes Why wont this line compile? (Assignment Java 4b) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Why wont this line compile? (Assignment Java 4b)" Watch "Why wont this line compile? (Assignment Java 4b)" New topic
Author

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

Rory Lynch
Ranch Hand

Joined: Aug 03, 2007
Posts: 95
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


I wish that for just one time, you could stand inside my shoes.<br />You'd know what a drag it is to see you.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11302
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rory Lynch
Ranch Hand

Joined: Aug 03, 2007
Posts: 95
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
Marshal

Joined: Mar 22, 2005
Posts: 41804
    
  62
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.


Ping & DNS - my free Android networking tools app
Rory Lynch
Ranch Hand

Joined: Aug 03, 2007
Posts: 95
Thanks Sherrif.

It's easy when you know the answer
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
[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)


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Rory Lynch
Ranch Hand

Joined: Aug 03, 2007
Posts: 95



got it.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1362
    
  17
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

Joined: Apr 29, 2007
Posts: 101
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

Joined: Jul 22, 2000
Posts: 9046
    
  10
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

Joined: Apr 29, 2007
Posts: 101
Marilyn -

Thank you thank you! I just tried it and it works beautifully!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why wont this line compile? (Assignment Java 4b)