Coding in java | SoloLearn: Learn to code for FREE!


Coding in java

How can i add new string into an array of strings like if i have a library class and i create an array of books and i want to add new book object into this array ( the max size is 50)

10/22/2019 7:55:46 PM

Nada Kolaghaci

2 Answers

New Answer


It sounds like you might be looking for something more like an ArrayList. Import it from the until package: import java.util.ArrayList; You can declare an ArrayList of Strings like this: ArrayList<String> myList = new ArrayList<String>(); From there, you can add and remove objects as you need. Using the respective ArrayList#add(E e) and ArrayList#remove(int index) methods. Also, I wrote an implementation of it if you would like to see how it works behind the scenes.


thank you , but i didn't take this method so i didn't want to get copy without understanding it :)