• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

String to Array of String

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
How to convert String to Arrayof String
for Eg. String mstrString ="this is the test string";
after converting
the value of mstrString will be assinged to strArr vaiable.
String strArr[] = { -- value of mstrString --};

i have a String and i want to pass the Array of String into the Array.sort(String[]) methode.

how can i do this ,


Please help me for this
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
its not very clear what you want to do actually.
but if you want to convert string to array of string like this

then you can use StringTokenizer which will extract the works for you from the string and then you can put it in array of string.
[ August 11, 2004: Message edited by: pinky yadav ]
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My intenstion is i have a string object and i want to convert this String object into ArrayofString object so that i will pass this ArrayofString object to sort method.

Let us see the Practical scenario
String mstrString = " this is the test string and want to convert it into array of String";
The output is it will return the Array of String
the function looks like

public String[] StringtoArry(String)
{
return String[];
}
}
 
pinky yadav
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you want whole string as one entry in array then do


if you want each word as seperate word in array then
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
Pinky Thanks for the same

I am writing the Webservice and this service will return the nuber of distincet word in the string , i done this by using this
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
StringTokenizer is a legacy class according to the 1.4.2 API.
You should use String.split(regex).

So to split a sentence up into an array of words:



Hope that helps
 
Dinner will be steamed monkey heads with a side of tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic