+ 2

Can you explain the commented part of this Java code? [link on description]

This is a simple code to capitalize every first letter of words in a sentence. https://code.sololearn.com/c1A5A12A10A1

1st Mar 2021, 3:09 PM
Ray
Ray - avatar
1 Respuesta
+ 2
You can learn about how substring method works by little bit of googling. as for captializeWord=" " , it is intialization of it with empty string , you will see now why it's important , The following code, "capitalizeWord+=first.toUpperCase()+afterfirst + " "; " Works like "capitialzeWord=capitializeWord+first.toUpperCase() + afterfirst + " "; if you didn't initialized it with empty string above you cudn't have done addition to it.
1st Mar 2021, 3:45 PM
Abhay
Abhay - avatar