DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links