Searching an array of Objects


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Searching an array of Objects

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    1

    Searching an array of Objects

    how would you go about searching lets say i have program like this

    Code:
     class records 
    {
                   string name ;
                    int age; 
                   
    void acceptvalues() throws IOException
    {
    //buffreader etc 
    system.out.println("Enter name");
    name = input.readLine());
    system.out.println("Enter name");
    name = input.parseInt(input.readLine());
    
    }
    void printrecords()
    
    {
    	print name 
    	print age 
    }
    
    main()
    {
    	records objrecords[] = new records[5];
    
    	for loop int i 
    		objrecords[i] = new records();
    		objrecods[i] = records();
    	end of loop 
    
    	printinf loop int k
    		objrecords[k].printrecords();
    }
    would like to give the user an option to print the 1 single record at a time..  
    searching by  name .. how would i accomplish this...  
    
    thanks

  2. #2
    Join Date
    May 2004
    Location
    Durham, UK
    Posts
    174
    What you need to do is to use a collection

    Look at the this information which tells you more about them and how to search them

    http://www.dcs.warwick.ac.uk/~zabin/slides3.pdf
    Hope this helps
    Graham

    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, and if they get mad, you are a mile away and you have their shoes ;-)

    http://www.grahamrobinsonsoftware.com

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