Thread: Infinte loop?

    #1
  1. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0

    Infinte loop?


    When I uncomment this loop, the page just hangs forever.
    I suspect it's looping infintly.
    Code:
    		int i = 0;	
    		while(tokens.hasMoreTokens())
    		{
    			del_arr[i] = tokens.nextToken();
    			i++;
    		}
    It says on javadocs tha hasMoreTokens() returns a boolean value, so when there's no more tokens, shouldn't it return false and kill the loop?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    78
    Rep Power
    11
    Yes, it should as long as it runs out of tokens.

    How big is the String that you are tokenizing?
    and
    What is your delimeter?

    Please, post your code include the setup of the Tokenizer so that we can get a better Idea of whats going on.
  4. #3
  5. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    it's something like 6542,6546,6542
    I figured it out though. I wasn't calling nextToken(), so it was always evaluating to true.

    My problem now is that the array i'm trying to store the token in is giving me a headeache.

IMN logo majestic logo threadwatch logo seochat tools logo