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

Recommended Answers

All 4 Replies

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.

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 =/

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.