So I have a big switch case in my main method. However it is way to long. I had the idea to put the different cases in a method each however, all of the cases contain break;and you obviously need a loop or switch case for a break;The break is also within the code. Any ideas on how I can do this?
You can make separate methods/functions for each action. Then inside the switch statement, you can call these methods. But if you want to avoid the switch statement, you can use Enums for different cases for example. So it would look something like this:
int f1(int arg1, int arg2...) {
//do something
}
void f2(int arg1, int arg2...) {
//do something
}
public static void main() {
switch(statement){
case 0:
f1();
break;
case 1:
f2();
break;
}
}