-1

it checks if the array needs more slots , if it does it adds 5 more slots to the original array while keeping the same content and order of the array

how could u do this in a method that returns true
and recieves add number to put in the array.?

public boolean add(int theNum)
{
.....
return true

}

please help idont understand

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by masijade
0

You can't add slots to an array. It's impossible. You can create a new array with 5 more slots however, and copy in the contents. Although I hope an instructor didn't tell you to do this because it is a bad idea - instead, double the size of the array.

0

say the array has an index of 0
then wen a person wants to add a say .. 27 to the first slot u cant just update it and add a slot?
cuz that wat i need to do =/

0

Once you create an array, you cannot add more indexes to it. If you need a bigger array, you'd have to do what I said in my first post. Just go read about arrays on google.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.