Java Java Basics Getting Started with Java Strings, Variables, and Formatting

my 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 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
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,633 Points

It 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 the console object for this challenge as opposed to System.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 of firstName