The quotation marks used indicate that the variable word
is of type String
, and prevents them from being treated as any other variable type. Similarly, values of type char
use single quotation marks to set them apart from other data types.
In this instance, initializing the String word
as ""
indicates that it is an empty string, but it has a value that can be accessed in memory to be overwritten later. Without this initialization, your program may think that the String word
has not been initialized and any operations on your object may fail.
For good measure, always initialize your variables with some value -- the empty string ""
will suffice in this case.