System.out.println(String apple);
System.out.println(String peach);
This is what was set to me
com/codegym/task/task01/task0135/Solution.java:15: error: ')' expected
System.out.println(String apple);
^
com/codegym/task/task01/task0135/Solution.java:15: error: illegal start of expression
System.out.println(String apple);
^
com/codegym/task/task01/task0135/Solution.java:16: error: ')' expected
System.out.println(String peach);
^
com/codegym/task/task01/task0135/Solution.java:16: error: illegal start of expression
System.out.println(String peach);
What is wrong in my code
Archived
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Norbert
4 March 2019, 12:09
The String should be used before println (declaration with value), try this:
String peach="Peach";
System.out.println(peach);
The others should be the same.
0
AK
4 March 2019, 07:25
Try System.out.println("apple");
0
Compi
3 March 2019, 21:35useful
just remove the type "String", and it will run.
+1
Usman Ali
3 March 2019, 20:59useful
The println() method accepts different type of arguments. It can accept primitive types such as string, int, long double and so on. But we don't declare the primitive variable in the println method. You initialize your peach variable outside the println method and pass just "peach" in the arguments.
Hope this helps.
+1
a95x
3 March 2019, 19:12useful
I think println doesn't accept this kind of argument.Once you created variable you type variable type and variable name after that you can call variable by variable name.If you try create variable with same name and type programm will be confused which variable to call and that is why this is not allowed.I hope this will help you :-)
+1