String Manipulation in java -
i have 1 array of strings. want each of string, divide in 3 parts (number-string-number), , put each part in array. @ last want have 3 arrays 2 of them store numbers , 1 of them stores strings. number of spaces between numbers , strings not fixed.
the format of strings in first array is:
-2.2052 dalam -2.7300
-3.0511 dan akan -0.1116
it great if me sample code.
here's algorithm implement :
- create 3 output arrays. should have same length original string array
- iterate through original array.
- for each string, find index of first space character , index of last space character. (look javadoc of string class methods doing that)
- extract substring before first space, substring between first , last space, , substring after last space. javadoc should you.
- convert first , third substring int (see javadoc double how it)
- store doubles , string ouput arrays.
Comments
Post a Comment