aspose file tools*
The moose likes Beginning Java and the fly likes Problem with a mock exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with a mock exam question" Watch "Problem with a mock exam question" New topic
Author

Problem with a mock exam question

Q Drini
Greenhorn

Joined: Jun 15, 2007
Posts: 5
Hi!

I was trying to compile code from a mock exam question, as I did not understand the result, but am getting a compiler error:

warning: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
(try -source 1.5 to use 'enum' as a keyword)
enum Roman {I, V, X, L, C, M }

Here is the code:



Could somebody please help? Btw, the result is 21.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

This code compiles and runs fine for me (once I add a line int z = 2;).

Your compiler "knows" about enum, but apparently isn't using it. So my guess is that you're using an IDE (like Eclipse) that is set to compile at a version lower than 1.5.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Q Drini
Greenhorn

Joined: Jun 15, 2007
Posts: 5
Marc,

Thank you very much for your reply.

I recently made the decision to switch to Java and have only started learning. Currently am going through the SCJP for Java 5 from Kathy S. and Bert B. The book reads very well and I feel comfortable reading it although, I find Self Test questions quite difficult.
I guess, I have given myself a tough deadline of three weeks to go through it and learn everything. Cannot even see my typing mistakes.

I didn't know where to start so I downloaded, from sun.com, the latest version of Sun Java Studio Creator (Version 2 Update 1 ) and I assumed it uses a compiler verson 1.5 or later. Maybe it doesn't.

Best Regards.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with a mock exam question