Output from array file within main class won't terminate - Any help!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Output from array file within main class won't terminate - Any help!!

  1. #1
    Join Date
    Nov 2005
    Posts
    44

    Output from array file within main class won't terminate - Any help!!

    Hi,

    Another simple question I think! Why is the output from this main class not terminating in the output window. The main method is calling an array of 10,000 integers from four seperate text files of telephone numbers. Each file is 10,000 integers long.

    When I run this main class it outputs the correct answer but simply does not terminate, and continually repeats the same answer.

    Code is as follows:

    Code:
    import simplejava.*;
     
    
    public class TelephoneApplication_AlgorithmTest 
    {
     
        public static void main(String[] args) {
            NumberListTester internal = new NumberListTester("INTERNAL.TXT");
            NumberListTester local = new NumberListTester("LOCAL.TXT");
            NumberListTester national = new NumberListTester("NATIONAL.TXT");
            NumberListTester international = new NumberListTester("INTERNATIONAL.TXT");
            
            SimpleWriter screen = new SimpleWriter(System.out);
            
            int givenNumber = 83743;
            
            while (givenNumber!=0) {
                if (internal.contains(givenNumber))
                    screen.println("Internal calls only.");
                else if (local.contains(givenNumber))
                    screen.println("Local and internal calls only.");
                else if (national.contains(givenNumber))
                    screen.println("National, Local and Internal Calls only");
                else if (international.contains(givenNumber))
                    screen.println("All calls permitted");
                else screen.println("Number not recognised.");
                
                System.out.println("First Search Complete");
                
               
                }
            }
        }
    Any help really appreciated!!

  2. #2
    Join Date
    Nov 2005
    Posts
    44

    Re: Output from array file within main class won't terminate - Any help!!

    Hi,

    Problem now solved. I was being a bit daft, and setting the int givenNumber to one value, whilst telling it to keep searching if the output was not 0.

    Anyway, all works perfectly now.

    Have a great weekend!!

Similar Threads

  1. Replies: 1
    Last Post: 02-26-2005, 09:50 AM
  2. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  3. Stored procedure output to a file
    By Dan Collins in forum VB Classic
    Replies: 1
    Last Post: 10-02-2001, 11:15 PM
  4. Replies: 6
    Last Post: 06-18-2001, 11:47 PM
  5. How To Do It - Shared Class Variables Part IV
    By Patrick Ireland in forum .NET
    Replies: 3
    Last Post: 05-07-2001, 03:04 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