165k views
1 vote
Examine the following:

String mess = "Hello" ;
mess = mess + " World" ;
What does the second statement do?

User Tiberius
by
8.6k points

1 Answer

3 votes

Final answer:

The second statement appends the string " World" to the variable mess, resulting in the combined string value "Hello World".

Step-by-step explanation:

The second statement in the given code concatenates the string " World" to the existing String variable mess, which already contains the value "Hello".

After this statement executes, mess will hold the combined value "Hello World". This operation is commonly used in programming to join or append one string to another.

User Darryn Campbell
by
7.3k points