I was doing my tutorial assessment, and realized I really don't get the 'switch' statement well some of it. I understand how to use it but why do the cases have to be compile-time constants (E.G initialized).

I guess my question is how does the program flow through it.

From my understanding it works like this:
Code:
public static void switchS(String <?>) {
    switch(<?>) {
   case A:            //code 1
    case B:            //code 2
    }
}
public static void main(String[] args) {
         switchS(A)

}
In my head it goes from the main method searchs the 'switch' statement till it finds a match then executes the following expressions. Why do the cases need to be initialized then?


P.S I was also wondering (not important just a random curosity the other questions is more pertinant to what I'm doing) what are the rules with cases can you put any amount of code in each case?

E.G:
Code:
case 1:    if(true) {
                   file(statement);
             } 
                    else {
                   file(suit);
                      erase(statement);
          };
is this appropriate use of the 'switch' statement?