
Elisha Ajayi
2,115 Pointsmy code is displaying illegal start of expression on line 1
illegal start of expression on line 1, i ran the same program on ide and it displayed y output please i need help with this
public class MyFirstName string;{
public static void main(String[] args){
// I have setup a java.io.Console object for you named console
//String firstName = "Tioluwase";
System.out.println("Hello, my name is Tioluwase \n", firstName);
System.out.println("Tioluwase is learning how to write java \n", firstNama);
}
}
1 Answer

Brendan Whiting
Front End Web Development Treehouse Moderator 81,972 PointsIt seems like there's a problem with class definition that you're using in your IDE. It shows string;
on line 1 where it would expect the opening {
.
As far as the challenge:
- You have the line commented out where you assign the variable
firstName
, but you need that for the other lines to work. - It needs you to be printing out exactly this phrase: "<YOUR NAME> can code in Java!" (So "Tioluwase can code in Java!"). You have something similar, but it needs to be exactly what they're looking for.
- Use the
printf
method on theconsole
object for this challenge as opposed toSystem.out.println
. This lets us print to the console as well as format the string, substituting variables for placeholder values. You'll need to be using the%s
placeholder in the string, which will be replaced by the argument you give. - You have a typo where you're using the variable
firstNama
instead offirstName