Results 1 to 4 of 4
- 08-01-2007, 02:25 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 33
- Rep Power
- 0
- 08-01-2007, 02:36 PM #2
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
I would guess that the student you are trying to remove is not found in the list so it is not reomving anything.
The reasons for this could be:
1) It isn't there
2) The equals method for the student in the list and the one you are passing in do not match.
Are you creating the student manually or retrieving it from the list prior to removing it?
If that's not the case then I think you need to provide a little more information then we can give you a bit more help
Regards :D
- 08-02-2007, 03:09 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 33
- Rep Power
- 0
This is my code
Java Code:public boolean remove(Student student) { if(student==null) { return false; } else { students.remove(student); return true; } }
- 08-02-2007, 03:26 PM #4
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
I was more after the code around what you have here.
How are you obtaining the student instance which you are passing in to this method?
Do you have a get method on this class which does :
Java Code:students.get(n);
Java Code:public Student findWithName(String name) { Student student = null; Iterator<Student> iterator = students.iterator(); while(null == student && iterator.hasNext()) { Student potential = iterator.next(); if(potential.getName.equalsIgnoreCase(name)) { student = potential; } } return student; }
Can you show me the code which calls remove and also the code for Student?
Thanks.
Similar Threads
-
How to convert List to Array
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:37 PM -
List views, a type of object
By Leprechaun in forum New To JavaReplies: 2Last Post: 02-06-2008, 04:07 AM -
Array List Problem
By khamuruddeen in forum New To JavaReplies: 1Last Post: 12-22-2007, 09:10 AM -
using an Array list
By toad in forum New To JavaReplies: 1Last Post: 11-18-2007, 10:08 PM -
Remove the bucket represented by the int from array
By barney in forum New To JavaReplies: 1Last Post: 08-01-2007, 09:55 AM
Bookmarks