Hello! I just want to know if I understand the program correctly. The program looks like this;
public class test{ static char bst = 'a'; static byte nr = 0; public static void main(String[] args) {{ char bst = 'c'; } switch(bst) { case 'a': nr = 1; case 'b': nr = 2; case 'c': nr = 3; case 'd': nr = 4; } Out.println("To "+bst + "belongs" +nr); } }
The output is "To a belongs 2", now the way I am interpreting this program is like this. We have this Class variable c that is initialzed as a and when we enter the switch after checking that it is a number 1 is assigned, but since there is no break we continue going down thus assigning number 2 where we exit the switch (via break). Am I understanding this correctly or ?