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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
prinln method you have only one argument.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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 ) ) ;
System.out.println( String.format( "%1$s, %2$s", x, y ) ) ;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.