Why does the continent.equals approach work here but not the switch? I don't understand why the switch doesn't evaluate correctly in this scenario. Thanks
static class HenFactory {
static Hen getHen(String continent) {
Hen hen = null;
//write your code here
if (continent.equals(Continent.AFRICA)) hen = new AfricanHen();
else if (continent.equals(Continent.ASIA)) hen = new AsianHen();
else if (continent.equals(Continent.EUROPE)) hen = new EuropeanHen();
else if (continent.equals(Continent.NORTHAMERICA)) hen = new NorthAmericanHen();
/*
switch (continent) {
case Continent.AFRICA: hen = new AfricanHen();
case Continent.ASIA: hen = new AsianHen();
case Continent.EUROPE: hen = new EuropeanHen();
case Continent.NORTHAMERICA: hen = new NorthAmericanHen();
}
*/
return hen;
}
}