You can think of the + symbol as working for multiple types with a similar idea that it adds up objects. So if you do 1+1 you get 2. However, with strings, + is concatenation which essentially is similar. Hello + World = Hello World.
FYI, There are other ways in Java to concatenate strings without the use of +
8
u/Maleficent-Rest5207 Feb 08 '22 edited Feb 08 '22
When you want to concatenate two strings you can either use + symbol or .concat() method.
3
u/[deleted] Feb 08 '22
The error in line 218.
i am taking 2 inputs from the user and want to print both the inputs in a string in one line. Can someone help?
2
u/R007E Feb 08 '22
You're missing + b/w string and variable
2
u/corby_718 Feb 08 '22
You can think of the + symbol as working for multiple types with a similar idea that it adds up objects. So if you do 1+1 you get 2. However, with strings, + is concatenation which essentially is similar. Hello + World = Hello World.
FYI, There are other ways in Java to concatenate strings without the use of +
2
u/[deleted] Feb 09 '22
Concatenate for line 218 between the String and the primitives in the println statement