Java Tutorials

Case keyword in Java

The case is used to label each branch in a switch statement. Remarks of Case keyword in Java
  • A case block does not have an implicit ending point.
  • A break statement is typically used at the end of each case block to exit the switch statement.
  • Without a break statement, the flow of execution will flow into all following case and/or default blocks.
  • Example
    
    int arg = ;
    switch (arg)
    {
    case 1:
    
    break;
    case 2:
    
    break;
    default:
    
    break;
    }
    


    No comments:

    Post a Comment