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); } }
7 Réponses
+ 3
metod append() works with BufferString.
I think here you needn't append
System.out.println(s+"Guys");
This is enough.
+ 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);
}
}
+ 1
Just run it in the code playground :)
+ 1
Martin Taylor It was my mistake instead of using concat() method I used append() method
0
Ya, your suggestion is good, But It's not answer of my question.