1. Read a character from the console:
public static void Main (String args[]) throws java.io.ioexception{
Char c= (char) System.in.read ();//read a character from the console;
Switch (c) {case ' 1 ':
System.out.println ("You are input is less than 3");
Default
System.out.println (c);
}
}
2. Break, continue, label, return control statement
(1) The loop terminates immediately when the break statement is encountered in the document Loop;
(2) The Continue statement is used to exit the current iteration of the loop without terminating the execution of the entire loop;
(3) The label label provides a way to control loops that a simple break statement cannot implement, and terminates when a break is encountered in a loop statement, regardless of other control variables. However, when you embed a condom and you want to exit the loop in a few layers of loops, you exit the loop in a normal break, and you can mark out which statement you want to exit.
eg
Char A;
outer://defines a label outer
for (int i=0;i<10:i++) {
for (int j=0;j<10;j++) {
A= (char) Systrm.in.read ();//read one character
if (a== ' B ')//If the character is B
Break outer;//Jump
if (a== ' C ')
Continue outer;
}
}
(4) return
The Ruturn statement is typically used at the end of a loop body to exit the loop and return a value. The data type of the return value must be the same as the return value type in the circular declaration.
Java Knowledge Consolidation