السلام عليكم
لقد قمت بكتابة كود string switch case وعند عمل كمبايل لا يعطي اي خطأ وعن تنفيذ هذا الكود دائما ينفذ الامر الذي داخل ال default
وهذا جزء من الكود بحيث ان المتغير sms عبارة عن String
String [] keys = new String [] {"Str1", "str2", "str3", "str4"};
switch(java.util.Arrays.asList(keys).indexOf(sms)) {
case 0:
{
System.out.println("first");
}
case 1:
{
System.out.println("second");
}
case 2:
{
System.out.println("therd");
}
case 3:
{
System.out.println("fourth");
}
default:
{
System.out.println("WRONG DATA");
}
}