Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enum to String array

 
Jonathan tse
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Due to some API constraint, i need to convert enum.values to a String array and couldn't find any handy library to do this task. Therefore, I write the following code but I just wonder if there is any better way to do this?

 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there and welcome to Javaranch!

I think what you have there is fine. Disclaimer, I'm not a world expert on Java .
 
Suresh Kumar Bethanasamy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can you please provide the examples for copying the enum values into an char array in java.

Thanks
Suresh
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Suresh.

Can you explain in more detail what exactly you want - how exactly do you want to store enum values in a char array? What output would you expect?
 
Suresh Kumar Bethanasamy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Welcome to the Ranch, Suresh.

Can you explain in more detail what exactly you want - how exactly do you want to store enum values in a char array? What output would you expect?


Dear Jesper,

Thanks for your mail.

My requirement is as follows

Copy the Enum Values into an array and display the values in the array.

Thanks
Suresh
 
Tony Docherty
Bartender
Posts: 2989
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My requirement is as follows

Copy the Enum Values into an array and display the values in the array.

The code has already been given for copying the enum values names into a string array. Your requirement is very similar although you state you want to use char array (why?) so you will need an array of arrays. You can use the code above as the basis of what you want to do.
If there is something which you don't understand then please say and we will explain it to you but we won't just write the code for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic