0
can I just add two string variables directly?
like system. out. println(s+t) where s and t are string took from user input.
4 Answers
+ 2
Yes you can. If you need a space between them you can do s + " " + t
+ 1
yes, you can use concatenation operator +
System.out.print(s1+" "+s2);
0
Hello Chitranjali...when you tries to add (+) two strings it concatenate to eac other and hence it will become one whole string like say s="abc" and t="def" if you write s+t it will become "abcdef"
0
Yes, concatenating strings is commonly used to add to strings, in the underlying calls to the String class methods that add strings or subsets of strings they use the '+' concatenation operator to add strings but overload the operator to perform specific tasks, append for example adds a string to the end of your original string.