You can't. If you need access to the previous element then you need to declare a variable and point this to the current value before you call the next() method.
John Vorwald wrote:You could use the ordinal method.
That depends on whether the OP is talking about an Enumeration or an Enum (enum). Given that he said "Enumeration" and is asking about the "previous element," my money is on Enumeration.
Jayasri kurra wrote:How to get previous element in Enumaration.
Why do you want to? And why are you using Enumeration in the first place? If you tell us WhatNotHow(←click), (that is, what are you trying to accomplish--going backwards with an Enumeration is just how you're trying to do it) someone can probably advise a better approach to attain your actual goal.
John Vorwald wrote:You could use the ordinal method.
That depends on whether the OP is talking about an Enumeration or an Enum (enum). Given that he said "Enumeration" and is asking about the "previous element," my money is on Enumeration.
Appears I need to read the question more carefully.... in order to avoid the dreaded "mouth in gear before brain is engaged" syndrome
Now we just need to hear back from the OP as to what he's actually trying to accomplish and why getting the previous element in an Enumeration is a solution to that problem.
That code appears to be the solution to a different question.
[edit]I see what has happened. You have interpreted the question as being about enumerated types, and used the values() array, whereas the original question was about the Enumeration interface, which I think is obsolete anyway.
If you want to look young and thin, hang around old, fat people. Or this tiny ad: