Home arrow static arrow Java Programming [Archive] - seperate strings
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - seperate strings
This topic has 2 replies on 1 page.

Posts:29
Registered: 5/27/03
seperate strings  
Aug 9, 2004 10:08 PM



 
how to seperate stirng ?
for example :

String date = "10-8-1992";

how to seperate this string into three different strings..
becoming "10", "8" and "1992".

can anyone please tell me how ?
 

Posts:18,384
Registered: 21.03.00
Re: seperate strings  
Aug 9, 2004 10:15 PM (reply 1 of 2)



 
Hi,

Look at String.split:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

/Kaj
 

Posts:37,103
Registered: 3/30/99
Re: seperate strings  
Aug 9, 2004 10:34 PM (reply 2 of 2)



 
or

http://java.sun.com/j2se/1.4.2/docs/api/java/util/StringTokenizer.html

I think String.split is now "preferred" over StringTokenizer, but it's still a valid solution. Pick what works best for you.
 
This topic has 2 replies on 1 page.