Tuesday, December 13
Syntax for using switch and while statements together - Loop, Repetition Statements in Java
Today we are going to explain switch and while statements, but by using standard input, ouput and Scanner object that can be found in java.util package. Quite simple with practicing to know how switch statement works in some case. Let,s take code an example which asks the user to enter the number of the month then will show an output with its name.
Code is explained in it and I will clarify while and switch statements as follows:
We used while to tell the loop to be 12 times only if the number is invalid until it get the true value from switch statement which has true values consist of 1 to 12 with names, that is. We used break to termenate or in other meaning escape if this value is true.
/* This is our simple program, and we
* write description text here allows with names
* or any related details about the programe
* You_Java.java
*/
* write description text here allows with names
* or any related details about the programe
* You_Java.java
*/
Subscribe to:
Posts (Atom)





