Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

StringTokenizer

0 views
Skip to first unread message

ego

unread,
Oct 7, 2005, 7:37:50 AM10/7/05
to

Hi, I have a question regarding StringTokenizer
I am using Jbuilder 9 Developer

I wrote the following code:


StringTokenizer st = new StringTokenizer(WordsForComboBox,",");
// WordsForComboBox = "Hello","Morning" ,"Amerika"


ArrayList Vl = new ArrayList ();


while (st.hasMoreTokens() )
{
String Value = st.nextToken() ;


Vl.add(Value);
} // while (st.hasMoreTokens() )


Object ia[] = Vl.toArray() ;


Arrays.sort(ia);


Well The Arrays.sort just doesn't work.


I tried to change to Vector , but the same result.


The Arrays.sort() is working fine when she is receiving an array that
was initialize with regular String value for example :
String fg[] = {"Hello","Morning" ,"Amerika"}


But when the array will be initialize through the StringTokenizer
function then the Arrays.sort will not work.
I tried also the following:
int le = ia.length ;
String rt[] = new String[le];
for(int i = 0; i<le; i++)
rt[i] = ia[i].toString() ;
Arrays.sort(rt);


The same result


Also the same when using the compareTo function


for(int j = 0; j < Te.length ; j++) {
for(int i = j+1; i < Te.length ; i++) {
String ValueB = (String)Te[i] ;
String ValueA = (String)Te[j] ;
if(ValueB.compareTo(ValueA) < 0)
{
String t = Te[j].toString() ;
Te[j] = Te[i];
Te[i] = t;


} // if(ValueB.compareTo(ValueA) < 0)


} // for(int i = j+1; i < Te.length ; i++) {
} //for(int j = 0; j < Te.length ; j++) {
Any ideas ?


Thanks ,


Ego

0 new messages