+ 6
5th Jun 2021, 9:50 AM
alagammai uma
alagammai uma - avatar
12 odpowiedzi
+ 3
You can use delimeter -here „a“- to format the string as follows String c=String.join(a,b,"");
5th Jun 2021, 10:00 AM
JaScript
JaScript - avatar
+ 12
the correct syntax for join is: String c=String.join(" ",a,b); // separation char is first argument that will return the output: "one two"
5th Jun 2021, 10:36 AM
Lothar
Lothar - avatar
+ 3
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.
6th Jun 2021, 3:24 AM
David Ordás
David Ordás - avatar
+ 2
Is your expected output is one two?
5th Jun 2021, 9:54 AM
Atul [Inactive]
+ 2
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
5th Jun 2021, 10:01 AM
Atul [Inactive]
+ 2
alagammai uma pls tell incase of anymore help
5th Jun 2021, 11:53 AM
Atul [Inactive]
+ 1
Atul nope Wanna know the reason why it's two
5th Jun 2021, 9:56 AM
alagammai uma
alagammai uma - avatar
+ 1
Sure
5th Jun 2021, 11:55 AM
alagammai uma
alagammai uma - avatar
0
Atul ok thanks
5th Jun 2021, 10:02 AM
alagammai uma
alagammai uma - avatar
0
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 😅
5th Jun 2021, 10:02 AM
Atul [Inactive]
0
David Ordás ok thank-you
6th Jun 2021, 3:26 AM
alagammai uma
alagammai uma - avatar
0
Please i don't know how start code help me
6th Jun 2021, 5:07 PM
Zakaria Sisu
Zakaria Sisu - avatar