Contents and Cities: Conditionals and Control Flow

Hello, I’m stuck with the Contents and Cities project:
https://www.codecademy.com/paths/introduction-to-android-with-java/tracks/programming-logic/modules/learn-java-conditionals-control-flow-u/projects/continents-cities

I reached the step 15 out of 16 and it fired a surge of errors.

Continents.java:7: error: illegal start of expression
         case = 1: System.out.println("North America: Mexico City, Mexico");
              ^
Continents.java:9: error: illegal start of expression
         case = 2: System.out.println("South America: Sao Paulo, Brazil");
              ^
Continents.java:11: error: illegal start of expression
         case = 3: System.out.println("Europe: Moscow, Russia");
              ^
Continents.java:13: error: illegal start of expression
         case = 4: System.out.println("Africa: Lagos, Nigeria");
              ^
Continents.java:15: error: illegal start of expression
         case = 5: System.out.println("Asia: Shanghai, China.");
              ^
Continents.java:17: error: illegal start of expression
         case = 6; System.out.println("Australia: Sydney, Australia");
              ^
Continents.java:17: error: : expected
         case = 6; System.out.println("Australia: Sydney, Australia");
                 ^
Continents.java:19: error: illegal start of expression
         case = 7; System.out.println("Antarctica: McMurdo Station, US");
              ^
Continents.java:19: error: : expected
         case = 7; System.out.println("Antarctica: McMurdo Station, US");
                 ^
9 errors

My code is here:

/*Planet Earth - quizzes for a continent and the largest city in that content*/
public class Continents {
	public static void main(String[] args) {
    
       int continent = 4;
       
       switch (continent) {
         case = 1: System.out.println("North America: Mexico City, Mexico");
           break; 
         case = 2: System.out.println("South America: Sao Paulo, Brazil");
           break; 
         case = 3: System.out.println("Europe: Moscow, Russia");
           break;
         case = 4: System.out.println("Africa: Lagos, Nigeria");
           break; 
         case = 5: System.out.println("Asia: Shanghai, China.");
          break;
         case = 6; System.out.println("Australia: Sydney, Australia");
           break; 
         case = 7; System.out.println("Antarctica: McMurdo Station, US");
           break; 
         default: System.out.println("Undefined continent!");
           break; 
    }
     
 

		

	}
}

I’d appreciate it if anyone could point out what went wrong as I couldn’t figure it out myself.

Does this look right? Your error message(s) literally point directly at the problems.
You can check out the docs for a quick review of switch...case syntax.

Oh yes, I think my eyes were so restrained that they couldn’t spot the errors. anyway, all good now. Thank you for the reference to that article.

1 Like