String Basics
String Basics
Strings in java is a sequence of characters that Is enclosed in double quotes. Whenever java comes across a String literal in the code, it creates a string literal with the value of string.
Example:
Output:
The same can be done using an array of characters.
Example:
Output:
Concatenate Strings:
Concatenation between two strings in java is done using the + operator.
Example:
Output:
Alternatively, we can use the concat() method to concatenate two strings.
Example:
Output:
What if we concatenate string with an integer?
Well concatenating a string and an integer will give us a string.
Example:
Output: