如何在Eclipse中将无输出固定到控制台窗口

时间:2019-07-09 09:21:07

标签: java eclipse switch-statement console-output

运行程序时,我的控制台窗口无输出,

试图选择其他控制台窗口,然后关闭然后重新打开该窗口,关闭其他打开的代码

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;

}
}
}

南美:巴西圣保罗(应该是正确的输出。)

1 个答案:

答案 0 :(得分:0)

然后应该是这样的:

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);