Results 1 to 9 of 9
Thread: Question on add method
- 06-03-2011, 04:29 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 11
- Rep Power
- 0
- 06-03-2011, 04:30 PM #2
Member
- Join Date
- Jun 2011
- Posts
- 11
- Rep Power
- 0
Can someone help me out on my add method. It has to add an element to the list (goals, assists, ppg, etc). I got the sort, remove, and count to work but no this. This is my project which is due today.
- 06-03-2011, 05:27 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,402
- Blog Entries
- 7
- Rep Power
- 17
- 06-03-2011, 05:43 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
- 06-03-2011, 06:30 PM #5
Member
- Join Date
- Jun 2011
- Posts
- 11
- Rep Power
- 0
I am using the removeOrAdd method, and in that method, the remove part works but not the add part. I tried doing new DataBase().processing(); but that does not add new elements to the previous elements.
Like for example.
List
Andrew
After adding,
(Andrew is not there anymore), but a new element(or s) is there.
Dan
Chris
- 06-03-2011, 06:33 PM #6
Member
- Join Date
- Jun 2011
- Posts
- 11
- Rep Power
- 0
Can you guys please help me out? This assignment is due in 2 hours. Sorry for rushing you guys. I worked hard on this code, and got everything to work except the adding elements part.
- 06-03-2011, 06:37 PM #7
Well, obviously the add part doesn't work. It's an empty block:
What have you tried to put in there?Java Code:if(newVal.equalsIgnoreCase("A")) { }Get in the habit of using standard Java naming conventions!
- 06-03-2011, 06:39 PM #8
Member
- Join Date
- Jun 2011
- Posts
- 11
- Rep Power
- 0
I left it blank because I don't understand what to put in there. I tried to put new DataBase().processing(); to call the whole processing method again, but it creates a new list instead of adding it to the previous list.
- 06-03-2011, 06:47 PM #9
Okay. Well, you need to create a new Pair object to put in the list. To do that, you'll need to get all the variables that make up a Pair object.
Looking at your definition of the Pair class, I really have no idea why you're passing an Object and a Comparable to its constructor. But the other arguments sound like things you should be getting from the user. So use the same techniques you've been using to ask the user for goals, assists, and gamesPlayed. Then use those values to create a new Pair object, and call List.add() to add it to the list.
List (Java Platform SE 6))Get in the habit of using standard Java naming conventions!
Similar Threads
-
WAIT method question
By alexalex1234 in forum Threads and SynchronizationReplies: 1Last Post: 03-14-2011, 11:37 AM -
add method from Arraylist - question
By Adomini in forum New To JavaReplies: 6Last Post: 10-21-2010, 07:08 PM -
return question for method
By Adomini in forum New To JavaReplies: 12Last Post: 09-02-2010, 04:55 PM -
split method question
By Chasingxsuns in forum New To JavaReplies: 3Last Post: 11-19-2009, 07:19 PM -
method question
By xplayerr in forum New To JavaReplies: 7Last Post: 11-11-2009, 04:13 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks