🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
1 messages
1 total messages Started by ego Fri, 07 Oct 2005 11:43
StringTokenizer
#312
Author: ego
Date: Fri, 07 Oct 2005 11:43
80 lines
2772 bytes

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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads