![]() ![]() If the case value after default does not match with the variable value (i.e. But this only happens when the case after default has the same value with variable value. If the case with the matching value as variable’s value is after the default statement, that case statement will execute without the default statement executing even if you put break after default. It can be placed anywhere in the switch block according to the required result. The default statement is meant to execute when there is no match between the values of the variable and the cases. Optional default case: default case value is optional.If a case is matched and there is no break statement mentioned, subsequent cases are executed until a break statement or end of the switch statement is encountered. Optional Break Statement: Break statement is optional in Java's switch statement.Primitives are allowed with their wrapper types. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |