this method 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 content in 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


Recommended Answers

All 2 Replies

Arrays are static--once you allocate them, they're pretty much stuck at that size. If you need a dynamic list, use ArrayList instead. Converting to an array is simple, use toArray(<type>) whenever you need to output.

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.