The program entered from the “Premium” case. Notice here that the println statement of the “Premium plus” case was not executed as the program did not enter the switch statement in this case. Let us run our program and check the results. ("Your hosting plan includes:") Ĭase "Premium plus": ("- Extra 1 CPU") Ĭase "Premium": ("- Extra 1GB RAM") Ĭase "Basic plus": ("- Unlimited bandwidth") Ĭase "Basic": ("- 2 Domain names") Since we can ristrict the entry point using the “case” keyword, we can write our program in a way that includes all the correct features by simply defining the switch case order from the most inclusive case to the least inclusive. Now, let us model this program in Java using a switch statement. The plan includes whatever is in the “Premium”, the “Basic plus” and the “Basic”, plus an extra 1 CPU.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |