Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

i have this. public Book[] bookCollection = new Book[20]; public void addBook(String title){ } how do i add an item to the array in Java?

OpenStudy (rsmith6559):

bookCollection[ x ] = new Book( title ); Where x is an integer between 0 and 19 in this case.

OpenStudy (anonymous):

its seems to be something incomplete u havent shown as what item book contains you want to add u just shown an object if its string array then u have to use loop with limit to 20 items and then add to array and there are several methods but i suggest instead of string array u should use linked list its easy to add remove items

OpenStudy (anonymous):

sorry instead of you i typed u its Facebook effect ;)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!