Ask your own question, for FREE!
Computer Science 15 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!
Latest Questions
Arriyanalol: i need help
2 days ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
2 days ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
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!