First, the method should have (), indicating the parameters
Second, you need to enter the int type, to determine whether the input is an int
Scanner scan = new Scanner (system.in);
if (scan.hasnextint) {
int a = Scan.nextint ();
}else{
SYSTEM.OUT.PRINTLN ("Invalid input:")
}
Third, Java design principles:
Low coupling and single principle
Judge the inside coupling degree is high (&&...&& Too much content)
Multiple variables can be problematic, or you may have unwanted results, and are not conducive to expansion, reading, understanding, and error-checking.
Iv. understanding of nested for loops
For a For loop nesting, you can have a clear idea
For example, the output multiplication table, output a variety of *
The first is a few lines, that is, the outermost loop several times.
Then there are the elements of each line, such as *, spaces, and so on, each line has a few, the number of each line to write down, and the number of rows of the mathematical relationship, that is, the second layer of the condition of the cycle of judgment. (mathematical expressions for several elements, and the number of rows)
1.20 Java Basics Summary input data Type Judging Java low-coupling principle for nesting ideas