i need only an example for deleting with shift in an array because i can't get it
:)
Printable View
i need only an example for deleting with shift in an array because i can't get it
:)
Please see the link in my signature entitled 'Getting Help'...you need to provide a lot more information if you wish to receive replies that aren't simply guesses.
i think (she?) means having a regular array, and wanting to use it as a list. so if she wants something in the middle deleted, she wants help moving the rest of the array over.
If this isnt specifically being asked for by the teacher, use ArrayList, it does all that for you.
otherwise say you want to delete the 4th index of an array named myArray
posDeleted = 3
for(int i=posDeleted; i< // the arrays length;i++)
{
myArray[i] = myArray[i+1];
}
something like that, but I have not used arrays for this job in a while so i forget the way to find out its length.
also, i should never reach the last index of the array, it should only reach the second last(because it grabs from one index higher)
also, you may want to make a new array that is smaller by 1 and be sticking everything in the new array to prevent lots of invalid data at the end not getting over ridden, or you can just write code to handle the last spot of the array and set it to a flag such as -1 or null
If someone wants their question to be answered concisely, then they should not assume we are mind readers and should provide all the information necessary. Feel free to guess, but given the information provided that is all it is at the moment - could be right, and could be wrong as shift could mean a great many things - moving array elements, deleting from an array using the shift key, and that doesn't even address what it means to delete (shorten an array, nullify elements, etc...). I say this because this poster has provided limited information in the past, and should learn that getting answers is intimately tied to how the question is asked.
ok i got the information i need
and i won't make my question too general again to find the wanted answer :)