Results 1 to 2 of 2
Thread: Searching an arraylist
- 04-15-2008, 02:46 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 6
- Rep Power
- 0
Searching an arraylist
The assignment requires that I write a program to update, maintain and query students' records on an ongoing basis. It requires a few things, but there's one in specific that I'm stuck on.
This is my Student class:
This is my Admissions class:Java Code:public class Student { private String id, firstname, lastname; Student(String i, String f, String l) { id = i; firstname = f; lastname = l; } String getid() { return id; } String getfirstname() { return firstname; } String getlastname() { return lastname; } }
My problem is under 2e. I need to "given an id number, locate that record on the list"Java Code:import java.util.ArrayList; public class Admissions { Student s; ArrayList<Student> list; int index; boolean found; //2a Admissions() { list = new ArrayList<Student>(); } //2b void add(Student s) { list.add(s); } //2c int size() { return list.size(); } //2d boolean isempty() { return list.isEmpty(); } //2e void search(String key) { if (list.s.getid().equalsIgnoreCase()) { ; } //Prof. didn't tell us how to do this. We need to figure it out, but I think it's with a while loop. } //2f Student remove(int i) { return list.remove(i); } }
Thanks!Last edited by adelgado0723; 04-15-2008 at 02:52 AM.
- 04-15-2008, 01:09 PM #2
Similar Threads
-
Searching XML file using DOM
By simon in forum XMLReplies: 5Last Post: 03-30-2009, 01:27 AM -
Java Project Trouble: Searching one ArrayList with another ArrayList
By BC2210 in forum New To JavaReplies: 2Last Post: 04-21-2008, 11:43 AM -
recursively searching through arraylists
By newtojava7 in forum New To JavaReplies: 1Last Post: 03-17-2008, 02:36 AM -
searching within a JList
By newtojava7 in forum New To JavaReplies: 1Last Post: 03-10-2008, 12:12 AM -
searching
By nalinda in forum New To JavaReplies: 3Last Post: 12-06-2007, 02:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks