Help with the MadLibs portion of the Java Class

Hi there, I can’t figure out where I am going wrong here, and apparently I have 18 errors. I declared and initiated all the variables…I’m pretty sure.I probably missed a step, but maybe you can help me out? This is what I have so far:
public class MadLibs {
/*
A program that runs Madlibs.
*/
public static void main(String args){

  //The template for the story
  String story = "This morning "+name1+" woke up feeling "+adjective1+". 'It is going to be a "+adjective2+" day!' Outside, a bunch of "+noun1+"s were protesting to keep "+noun2+" in stores. They began to "+verb1+" to the rhythm of the "+noun3+", which made all the "+noun4+"s very "+adjective3+". Concerned, "+name1+" texted "+name2+", who flew "+name1+" to "+place1+" and dropped "+name1+" in a puddle of frozen "+noun5+". "+name1+" woke up in the year "+number+", in a world where "+noun6+"s ruled the world.";
  String name1 = "Johnny";
  String adjective1 = "nasily";
  String adjective2 = "loftily";
  String adjective3 = "swiftly";
  String verb1 = "flies";
  String noun1 = "mouse";
  String noun2 = "pencil";
  String noun3 = "paper";
  String noun4 = "teeth";
  String noun5 = "piano";
  String noun6 = "water";
  String name2 = "Horacio";
  int number = 14;
  String place1 = "New York City";
  
  
    

 
    
}       

}

1 Like

Try using String story after declaring the other variables.

The error is most likely caused by the fact that the story is searching for these variables before they are declared.

2 Likes

Do you mean put the declared variables before the String story? The story was previously set before the variables, so I’m still unsure of what to do.

1 Like

Yes, place the declared variables before String story.

If you get further errors could you send me the url of the activity.

1 Like

Wow, that worked. Is it simply because the story needs to know the variables before the story is said?

1 Like

That’s right.

To retrieve information from a variable, the variable needs to set beforehand.

2 Likes

Alright, I understand now. Thanks.

1 Like