Problem:
Hello Kodlogs,
I am feeling good to find a helpful website like this. So many nice, and friendly people are here.
Let me come to the point and put my problem here. I am new to java programming and trying to learn new things every day. I just found a new thing called Switch-Statement.
So, I read about it thoroughly and tried to write a code using the Switch-Statement, but the problem is it returns me an error (the default case must be specified in a switch statement.) instead of my expected output.
Here is my program snippet.
public class Practice {
public static void main(String[] args){
int weather = 5;
String dayString;
switch (weather) {
case 1:
dayString = "Sunny";
break;
case 2:
dayString = "Rainy";
break;
case 3:
dayString = "Windy";
break;
case 4:
dayString = "Snowy";
break;
case 5:
dayString = "Cloudy";
break;
}
System.out.println(dayString);
}
}
Please shed some light on this. Thanks.