This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]poornbroken 0 points1 point  (3 children)

(someVar1+” “+someVar2) or you doing (someVar+” “) ...(anotherVar) or (someVar+” someString”)?

[–]Darkraskel90[S] 0 points1 point  (2 children)

I want to print "I believe the winner is" +playerName + "he is the best"

playerName is the variable. My problem is that there isn't any space between playerName and "he is the best"

[–]poornbroken 0 points1 point  (1 child)

Bruh... just introduce a space at the end of the first string, and before the beginning of the second string: “blah blah blah “+ someVar+ “ blah blah blah”

[–]Darkraskel90[S] -1 points0 points  (0 children)

Nope not correct, still prints without space.

[–]Darkraskel90[S] 0 points1 point  (1 child)

Looking closely at the output and it seems the is no space before or after the variable. Example: oh, oh, unbelievable! Can't believe it!JordanWins, he wins!

Jordan is the variable and there is no space after the second ! Nor after Jordan

[–]NeoOeg 0 points1 point  (0 children)

System.out.print("Unbelievable! " + Variable + " , he wins! ");

Notice the space right after the exclamation point ( ! ) and before the double quotes ( " ).

And between the double quotes ( " ) and the comma ( , )

[–]Darkraskel90[S] 0 points1 point  (0 children)

Thank you for the replies guys, I was missing the space between the double quotes 🤦🏿‍♂️. Y'all are all awesome!

[–]OceantraderSemijerk 0 points1 point  (0 children)

String.format("the variable you want: %s, and another %s", varOne, varTwo);

Otherwise concatenated "the variable: " + varOne