Declaring an array help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Declaring an array help

  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Declaring an array help

    I am writing a program that will have a input file that will have a person's name and id number information on the file. I have to make this file my array for my program b/c the user will type in either the name of the person and have the id# returned or the user will enter the id# and the name will be returned. The problem I am having trouble with is when setting up the array which will be a 2-D array how do i set the size of the array to the number of entries in the file? The reason why I want to do this is incase the number of records the file has increases or decreases.

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    ArrayList
    Check out this one.
    This should do just what you want, since it's an array you can extend dynamically. You need to extend your array dynamically since there is now way to know beforehahnd how many lines a file has. With the ArrayList, you can just add a new entry each time you read a line. Since the ArrayList takes Objects in the add method, you can add other arrays as well, thus creating the 2d array you want.

    There are more then enough methods in there to do what you want, just check it out.

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