1.20 Java Basics Summary input data Type Judging Java low-coupling principle for nesting ideas

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.