0

What will be output of following java program.

class Test{ public static void main (String[] arg){ String s = "Hello"; s.concat("Guys"); System.out.println(s); } }

8th Sep 2020, 4:39 AM
FzTechnology ken
FzTechnology ken - avatar
5 Respuestas
+ 3
metod append() works with BufferString. I think here you needn't append System.out.println(s+"Guys"); This is enough.
8th Sep 2020, 6:06 AM
Muhammadamin
Muhammadamin - avatar
+ 3
It gives Error that can't find the symbol. There variable s should be object. Try this class Test{ public static void main (String[] arg){ StringBuffer sb = new StringBuffer("Hello"); sb.append(" Guys"); System.out.println(sb); } }
8th Sep 2020, 6:16 AM
Muhammadamin
Muhammadamin - avatar
+ 1
Just run it in the code playground :)
8th Sep 2020, 4:46 AM
NULL
NULL - avatar
+ 1
Martin Taylor It was my mistake instead of using concat() method I used append() method
8th Sep 2020, 12:15 PM
FzTechnology ken
FzTechnology ken - avatar
0
Ya, your suggestion is good, But It's not answer of my question.
8th Sep 2020, 6:10 AM
FzTechnology ken
FzTechnology ken - avatar