0
HOW TO PRINT int and String ? System.out.print("your age is :", 12); the code above take me to an error -_-
6 Answers
+ 1
You're using a comma, which is for formatted prints with % values for arguments. Use + in your case.
System.out.print("your age is: " + 12);
to do format would be like
System.out.printf("your age is: %d", 12);
and to Aquarius, you don't need to set the number to a variable for it to work. It's good coding, but not required.
Aady, you don't need to add ln unless you want to print separate lines. print works just fine.
0
because you need to set a variable thats set to your example 12 and then when you do println you put example:
System.out.println("Your age is " + age);
0
No variable is required. Comma should be replaced by +, it is a concatenation operator here!
0
thanks James
0
int a=12;
System.out.println("Age="+a);
0
just replace this :
int age = 12;
System.out.println("your age is : " + age);