This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with a mock exam question

 
Q Drini
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Q Drini
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic