🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #312

StringTokenizer

#312
From: 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
Technical Details
Message-ID: <1128685394.366142.31680@o13g2000cwo.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,1dd81ca17e8fd038,start
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail
From: "ego" <kizer25@hotmail.com>
Newsgroups: borland.public.jbuilder.java.language
Subject: StringTokenizer
Date: 7 Oct 2005 04:43:14 -0700
Organization: http://groups.google.com
Lines: 81
Message-ID: <1128685394.366142.31680@o13g2000cwo.googlegroups.com>
NNTP-Posting-Host: 62.0.74.55
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1128685399 13159 127.0.0.1 (7 Oct 2005 11:43:19 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 7 Oct 2005 11:43:19 +0000 (UTC)
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: o13g2000cwo.googlegroups.com; posting-host=62.0.74.55;
   posting-account=EE3GpA0AAAChnLDPl8gdvkWA3e1VdVqr