Results 1 to 4 of 4
Thread: Compacting arrays.
- 11-07-2010, 10:41 PM #1
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
- 11-07-2010, 11:22 PM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
If you are allowed by the assignment requirements, don't use an array but rather an ArrayList. It's built for just this sort of thing.
- 11-07-2010, 11:31 PM #3
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
Yea i actually need to just add a "remove method" to one of Cd collection classes in the book. Dont no what to do.
- 11-07-2010, 11:40 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,539
- Rep Power
- 11
In very general terms you would get the index of the CD in the collection then, starting from the next position in the array copy each element one place towards the start. Think about what you would do when you reach the end of the array.
Bear in mind that we don't have this book so it's rather hard to give more than very general advice without seeing some code (and preferably your attempt: either of the previous paragraph or something you can come up with.)Java Code:to delete == arr[4] | v A B C D E F G H A B C E E F G H copy arr[5]->arr[4] A B C E F F G H [6]->[5] A B C E F G H H [7]->[6] A B C E F G H ? ?
Similar Threads
-
store array of arrays in array of arrays
By joost_m in forum New To JavaReplies: 4Last Post: 04-19-2010, 10:32 AM -
Arrays.sort... why sorting all arrays in class?
By innspiron in forum New To JavaReplies: 6Last Post: 03-23-2010, 01:40 AM -
2D Arrays
By Major90 in forum New To JavaReplies: 6Last Post: 11-06-2008, 02:08 PM -
Need help with Arrays
By dietgal in forum New To JavaReplies: 21Last Post: 10-08-2008, 01:59 PM -
Help with Arrays
By bri1547 in forum New To JavaReplies: 4Last Post: 08-01-2008, 05:12 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks