program ends after while loop??


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: program ends after while loop??

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    program ends after while loop??

    My program keeps ending after each while instead of continuing down the algorithm.
    example:
    Code:
    while(f1 != null)
    			{//3
    				f1 = inFile.next();
    				id1 = f1;
    				f1 = inFile.next();
    				pd1 = f1;
    				f1 = inFile.next();
    				p1 = f1;
    		try
    	  {
    			          price = Double.valueOf(p1.trim()).doubleValue();
          }
          catch (NumberFormatException nfe)
          {
             System.out.println("NumberFormatException: " + nfe.getMessage());
    	  }
    				System.out.println( id1 + " " + pd1 + " " + " " + price);
    			}//3
    it ends after the last println for some reason

  2. #2
    Join Date
    Dec 2009
    Location
    UK
    Posts
    3
    the only way it can leave the loop in this situation is if f1 is set to null from your final

    Code:
    f1 = inFile.next();
    I would imagine that inFile ends earlier than you are expecting.

Similar Threads

  1. Replies: 26
    Last Post: 12-01-2012, 04:12 AM
  2. Replies: 1
    Last Post: 08-12-2007, 09:38 PM
  3. Program Watcher
    By westweb in forum VB Classic
    Replies: 8
    Last Post: 06-11-2007, 03:17 PM
  4. help, dont know why program is too slow
    By bob2000 in forum Java
    Replies: 1
    Last Post: 02-18-2007, 07:43 PM
  5. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 10:06 AM

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