• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String to Strin[] conversion

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am trying to convert a String to String[].
String a = "abc";
String[] temp = (String[]) a;
What am I doing wrong here?
Thanks,
Kaj
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want an array of characters? If so, try the toCharArray() method of the String class.
Do you want an array of Strings, the first of which is equal to "abc"? If so, first create the String array, declaring the desired number of items it will hold, then set the 0th item to "abc" or a variable that contains it.

Or, try this

Or, if you need a container with a variable amount of storage, have a look at the collections classes in the java.util package.
Or, do you want something else?
Finally, this post is off-topic for the J2EE forum. In the future, please find the most appropriate forum and post to it; there are many from which to choose.
HTH,
Craig
[ August 28, 2002: Message edited by: Craig Demyanovich ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic