Converting variables to string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Converting variables to string

Hello So I'm still a newbie at this and i try to write codes as I progress. I have learnt how to print out strings but i also discovered i cant print out variables i have defined without converting them to strings. In my code titled mix up you'll see that i could only print out Name because it is already a variable of string type. Could someone teach me how to print out other variables that are not strings? i.e int, double, boolean, char etc..Kindly refer to my codes "mixup". Thank you. Deedee

17th Jul 2019, 9:03 AM
DEEDEE ENESHAH
DEEDEE ENESHAH - avatar
4 Answers
0
It's not that they are different datatypes, but you used commas (,), instead of peroids (.) Also, you can include codes in your questions.
17th Jul 2019, 9:15 AM
Airree
Airree - avatar
+ 3
The same applies for other datatypes you would store numbers in variables of type int. int x = 10; System.out.print(x+x);
17th Jul 2019, 9:32 AM
D_Stark
D_Stark - avatar
0
I have fixed it, Thank you.
17th Jul 2019, 9:29 AM
DEEDEE ENESHAH
DEEDEE ENESHAH - avatar
0
Thanks a lot...I'm loving this.
17th Jul 2019, 11:47 AM
DEEDEE ENESHAH
DEEDEE ENESHAH - avatar