I suspect you want to add a break;
at the end of your case
blocks. Otherwise the code just runs from top to bottom (like anywhere else in your code)
If you place a break;
it will jump outside the switch
block which appears to be what you want.
e.g.
case AROHA_INCREASING: {
if (swaraPool.indexOf(endStr) < swaraPool.indexOf(startStr)) {
System.out.println("End string is before the start String");
return (-1);
}
break; // without this, the thread will run the next case: block.
}
solved Unreachable code in swtch statement