Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialElisha Ajayi
3,433 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 Techdegree Graduate 84,738 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