Question: ```
class switch1
{
    public static void main(String args[])
    {
        int a = 10;
        switch(a)
        {
            default: System.out.println("Default");
            case -1: System.out.println("-1");
        }
    }
}

```

I understand that this program will execute both "default" and "case -1" statements as break is not specified after the matching condition (in this case after "default").

But what I fail to understand is

a) why is `break` needed in a `switch` statement?

b) why does it even execute the invalid matching conditions' statements (i.e executing "case -1")) if all it does is matching?

Answer: 
`switch` statements without `break`s let you do things like this:

```
// Compute the most significant bit set in a number from 0 to 7
int topBit = -1;
switch(n) {
case 0:
    topBit = 0;
    break;
case 1:
    topBit = 1;
    break;
case 2:
case 3:
    topBit = 2;
    break;
case 4:
case 5:
case 6:
case 7:
    topBit = 3;
    break;
}

```

Essentially, it lets you create a set of labels, and have a condition at the top to let you jump to the initial label once. After that, the execution continues until a `break`, or reaching the end of the `switch`. This technique is old - it has been around since the assembly times, and by virtue of being included in C has made its way into Java and several other languages.
If you add break to a loop, it cancels out of the loop. so for a switch statement it goes to the correct case and once it is there it carries out the code until the `break` where it will then exit the switch statemnt. If you removed the break it would carry on to the next `case` and until is sees a break. If there are no `break;` the code will crash.

So basically it separates different cases