+ 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); } }
4 Réponses
+ 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.
+ 2
thank you so much KINGDX i was reading forum explanations and it was too advanced for a rookie 🤗
+ 2
you are using different Token
in printing part it must not be this ' ' you should use this token " "
0
thank you Ethan Franklin i did all the above and still not working.