Java Java Data Structures Efficiency! Custom Serialization

Kevin Carl David
Kevin Carl David
10,189 Points

Question about the array of strings in the loader

Hi,

in regard with the array of string being created in each line for the loader(title, artist and URL), I was just wondering how come even if the artist/title is more than 1 word, the size of array doesnt increase?

thanks

1 Answer

Livia Galeazzi
PRO
Livia Galeazzi
Java Web Development Techdegree Graduate 19,901 Points

Hi! A String is a collection of characters. It doesn't matter if some of those characters are spaces. This is one String:

String stringWithOneWord = "Martha";

This is also one String:

String stringWithTwoWords = "Martha Jones";

And this too:

String stringWithFullSentence = "Martha Jones loves software development and chocolate!";

So the array of strings just stores one more string, and it doesn't care if there are several words inside that string. In fact that array does not know that this string contains several words.