loop problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: loop problem

  1. #1
    Join Date
    Mar 2006
    Posts
    8

    Question loop problem

    Hi all;

    I have a problem regarding my loop.The code is below:


    StringTokenizer wordFactory = new StringTokenizer(myNewString);

    while (wordFactory.hasMoreTokens())
    {
    //get the next word from the sentence
    Aword = wordFactory.nextToken();
    long time = System.currentTimeMillis();

    }


    let me explain how the code works.

    the input is "aaa bbb ccc" and it is suppose to print one by one and the output will be printed out one by one, aaa then bbb and then ccc.

    i do this method since i want to track the time of each word with brute force method :

    for(char r = 'a'; r <= 'z'; r++){
    first = r;
    for(char s = 'a'; s<='z'; s++){
    second = s;
    for (char t = 'a'; t <= 'z'; t++){
    third = t;
    anotherWord=String.valueOf(first)+second+third;
    if(anotherWord == Aword){
    System.out.print(anotherWord)
    //track the time when anotherWord == Aword
    }
    }
    }
    }

    my problem is, once "aaa" has been detected by the code, how can i proceed to detect "bbb" and "ccc"?

    i really appreciate anyone's help. if the problem explanation is quite blur, u can ask me to explain in detail!

    thanx in advance!

    regards;
    dulcinea

  2. #2
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    In the javadoc to StringTokenizer you can see the following example:
    Code:
    StringTokenizer st = new StringTokenizer("this is a test");
    while (st.hasMoreTokens()) {
       System.out.println(st.nextToken());
    }

Similar Threads

  1. a very weird problem (AGAIN!!!)
    By Michael in forum ASP.NET
    Replies: 14
    Last Post: 02-24-2006, 09:54 AM
  2. Me again! This time its a loop problem
    By 0402900 in forum Java
    Replies: 12
    Last Post: 01-25-2006, 04:35 PM
  3. Strage problem with while loop (urgent)
    By hddd12345678910 in forum Java
    Replies: 5
    Last Post: 01-17-2006, 06:34 PM
  4. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 05:40 AM
  5. Replies: 0
    Last Post: 12-13-2001, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center