Forums Register Login

Help with System.out.print command

+Pie Number of slices to send: Send
Hi every body

I hope everyone is doing great. Please consider the following

Int a= 11,
String b= " Joe";
String c=" Ashley dr";


The goal is to pass these variables as parameters to " System.out.println command " so that we can display on screen the output: 11 Joe Ashley dr

How can i pass these variables as parameters ?

I tried:

System.out.println ( a, " ", b, " ", c);

But compiler kept giving error.




I hope someone could help with this.

Thanks and have a great weekend.





"
1
+Pie Number of slices to send: Send
Sarah,
Welcome to CodeRanch!

That's close. You build one string with a + like:

+Pie Number of slices to send: Send
Thanks Jeanne.
+Pie Number of slices to send: Send
The print statement's argument will finally be rendered as String.
Hence "+" should be used for concatination as already pointed out in the post above
+Pie Number of slices to send: Send
 

Jeanne Boyarsky wrote:


Or using the "new" printf method:
+Pie Number of slices to send: Send
 

sarah sturgeon wrote:But compiler kept giving error.


Please, in the future, tell us exactly what the error says. Believe it or not, those error messages tell you a LOT about what the problem is. Learning how to read them is a valuable skill that will save you hours of time in the future.

Simply saying "i get an error" is often meaningless. There are too many things it could be for anyone to give you any real help (most of the time).
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1367 times.
Similar Threads
Including External files......?????
Help : proxy server !!!!
Static Initializers
cohesion question
pls help exams are on my head
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:43:55.