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 trial

Java

ERROR: CANNOT FIND SYMBOL

Hi guys, I've copied the following code from the Java Basics workspace and am trying to run it but get the error: cannot find symbol String[] rsvps = Rsvps.shuffled();.I know this error is related to an undeclared variable . Unless I'm wrong this variable seems to have been declared on line 7. I'd really appreciate some help.Thanks

import java.io.Console;

public class Prizes {

  public static void main(String[] args) {
    Console console = System.console();
    String[] rsvps = Rsvps.shuffled();
    int prizesGivenAway = 0;
    int drawingNumber = 0;

    while (prizesGivenAway < 5) {
      String winner = rsvps[drawingNumber];
      drawingNumber++;
      console.printf("Is %s present?  ", winner); 
      String isHere = console.readLine();
      if (isHere.equalsIgnoreCase("no")) {
        continue;
      }
      String size = console.readLine("What is your shirt size?  ");
      prizesGivenAway++;
    }

  }

}

Will do thanks.

1 Answer

Make sure you add the import for the Rsvps class.