How two gets printed? https://code.sololearn.com/ckkSTVw6VRHU/?ref=app
6/5/2021 9:50:29 AM
alagammai uma12 Answers
New AnswerYou can use delimeter -here „a“- to format the string as follows String c=String.join(a,b,"");
the correct syntax for join is: String c=String.join(" ",a,b); // separation char is first argument that will return the output: "one two"
alagammai uma The right answer is like Lothar says. First goes the delimiter and then strings to merge. Look at api docs 👇 https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/String.html#join(java.lang.CharSequence,java.lang.CharSequence...) 📚 If you want know how is implemented, you should take a look at StringBuilder or StringBuffer classes.
I think so because there is no delimeter Because join takes a delimeter and it doesn't get it in your code. So printing the last string b
public class Program { public static void main(String[] args) { String a="three"; String b="onetwo"; String c=String.join(a,b); System.out.println(c); } } //I think so I am correct 😅
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message