javaeclipseswitch-statementconsole-output

how to fix no output to console window in eclipse


When running program I have no output to my console window,

Tried selecting different console windows, closing and reopening the window, closing other open code

package Codecademy;

public class Continents {
public static void main(String[] args) {
//This will show a continent and the largest city
    int contient = 4;
    String contientString;

    switch (contient) {
    case 1:
        contientString = "North America: Mexico city Mexico";
        break;
    case 2:
         contientString = "South America: Sao Paulo, Brazil";
break;
case 3:
contientString = "Europe: Moscow, Russia";
break;
case 4:
contientString = "Africa: Lagos, Nigeria";
break;
case 5:
contientString = "Asia: Shanghai, China";
break;
case 6:
contientString = "Australia: Sydney, Australia";
break;
case 7:
contientString = "Antarctica: McMurdo Station, US";
break;
default:
contientString = "Invalid Selection";
break;

}
}
}

South America: Sao Paulo, Brazil (Should be the correct output.)


Solution

  • Then it should be something like this:

    int contient = 4;
    String contientString;
    
    switch (contient) {
        case 1:
            contientString = "North America: Mexico city Mexico";
            break;
        case 2:
            contientString = "Some 2nd Continent: Some 2d City Some2ndCountry";
            break;
        case 3:
            contientString = "Some 3rd Continent: Some 3rd City Some3rdCountry";
            break;
        case 4:
            contientString = "Some 4th Continent: Some 4th City Some4thCountry";
            break;
        default:
            contientString = "Don't Know What Continent: UNKNOWN";
    }
    
    System.out.println(contientString);