Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please explain - code output

 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is one of questions from master mock exam. can you explain how to arrive at th eoutput please.
--------------------

 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you tried to run the code in a debuggerto see what is happening?
 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with my own debugs but failing to understand the concept.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps.
 
jibs parap
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's been quite helpful. Thanks very much MArk for your time.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, If you have a eclipse IDE [Open source www.eclipse.org] just put a break point and you will be able to trace the code.
Or better would be to take a pen and paper and note down the values of x and z after each iteration.

Thanks
Deepak
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also ordinal()
public final int ordinal()
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures, such as EnumSet and EnumMap.

Returns:
the ordinal of this enumeration constant

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Enum.html#ordinal()

Thanks
Deepak
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic