I need help, can some one explain to me what im doing wrong with this code. I tried different ways and no luck. Thanks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need help, can some one explain to me what im doing wrong with this code. I tried different ways and no luck. Thanks

class MyClass { public static void main(String[] args) { String name ="David"; int age = '42'; double score ='15.9' char group ='Z' System.out.println(name+""+age+'years old & has score:'+'15.9'+'in group'+Z); } }

14th May 2018, 1:47 AM
flor Reyes
flor Reyes - avatar
4 Answers
+ 2
Here is a working version of your code: public class Program { public static void main(String[] args) { String name ="David"; int age = 42; double score = 15.9; char group ='Z'; System.out.println(name+" "+age+"years old & has score:"+score+"in group"+group); } } What was wrong : -missing semicolon for age and score variables -you don't need quote marks for ints and doubles - when you printed your variables, there was a mixture between single and double quotes. You should choose one of either and not use the two interchangeably.
14th May 2018, 2:03 AM
CHMD
CHMD - avatar
+ 2
thank you so much KINGDX i was reading forum explanations and it was too advanced for a rookie 🤗
14th May 2018, 2:10 AM
flor Reyes
flor Reyes - avatar
+ 2
you are using different Token in printing part it must not be this ' ' you should use this token " "
14th May 2018, 2:59 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
0
thank you Ethan Franklin i did all the above and still not working.
14th May 2018, 3:12 AM
flor Reyes
flor Reyes - avatar