I came across this basic question, where switch case is used with string.
Break statement is not used between cases but why it going to all the cases even when it is not matching the case string?
So I'm curious to know why is the output 3 and not 1?
public static void main(String [] args)
{
int wd=0;
String days[]={"sun","mon","wed","sat"};
for(String s:days)
{
switch (s)
{
case "sat":
case "sun":
wd-=1;
break;
case "mon":
wd++;
case "wed":
wd+=2;
}
}
System.out.println(wd);
}