Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)
I've the enum type ReportTypeEnum that get passed between methods in all my classes but I then need to pass this on the URL so I use the ordinal method to get the int value. After I get it in my other JSP page, I need to convert it to back to an ReportTypeEnum so that I can continue passing it.

How can I convert ordinal to the ReportTypeEnum?

Using Java 6 SE.

1 Answer

0 votes
by (46k points)

To change an ordinal into its enum represantation you might require to try this:

ReportTypeEnum value = ReportTypeEnum.values()[ordinal];

Please mark the array bounds.

Remark that every call to values() delivers a newly cloned array which sways impact appearance in a negative fashion. You may require to cache the array if it's performing to be called frequently.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 23, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer

Browse Categories

...