Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Array of array of char to String array  RSS feed

 
Chris Yates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a faster way after filling array of array of char to convert it to String array? Instead of looping like i did? I know its possible to give char array in constructor but doesnt seem to work with char[][].

 
salvin francis
Bartender
Posts: 1612
36
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Honestly I dont quite get what you are trying to accomplish, here is a bit re-factoring on your code :



Note: this can be still optimized
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Yates wrote:I know its possible to give char array in constructor but doesnt seem to work with char[][].

It won't work with char[][] because the constructor would have to be able to construct an array of Strings and a constructor can only construct an instance of its class ie a String.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Chris: I would just add that neither a char[][] nor String[] strike me as very good solutions to your problem, which is how to hold a set of hands of cards.

You might want to check out the StringsAreBad article for some reasons why.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!