Link to home
Start Free TrialLog in
Avatar of JRawabi
JRawabi

asked on

printing more than one variable using System.out.print

Hi

This is really simple but I am very new to Java.
Can we print more than one variable using a single  System.out.print  like this

System.out.println(x,y);

It is giving an error.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
prinln method you have only one argument.
SOLUTION
Avatar of Sharon Seth
Sharon Seth
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JRawabi
JRawabi

ASKER

System.out.println(x+"x..y.."+y);

Why you have to concatenate to  "x..y" ?

Can't I just print more than 1 variable?
to print simply the variables,

System.out.println( String.format( "%1$s, %2$s", x, y ) ) ;
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial