Learning java together [7] --- first understanding of structured, object-oriented

Source: Internet
Author: User

In 1996, computer scientists Bohm and jacpini demonstrated the fact that any simple or complex algorithm can be combined by three basic structures: sequential structure, Selective structure, and cyclic structure.
 
Therefore, these three structures are called the three basic structures of program design and must be used in structured program design.
 
1. Ordered Structure:
Example: public class Shunxu
{
Public static void main (String [] args)
{
Int a = 1;
Int B = 2;
 
Int c = a + B;
Int d = a-B;
 
System. out. println (c );
System. out. println (d );
}
} This code is a typical ordered structure. It is executed step by step without skipping any line of code. When d is output at the end, all the above Code has been executed.
 
2. Select the structure:
Public class Shunxu
{
Public static void main (String [] args)
{
Int a = 1;
Int B = 2;
Int c = 3;
Int d = 4;
 
If (a> B)
{
System. out. println ();
}
Else
{
If (a = B)
{
System. out. println (B );
}
Else
{
System. out. println (c );
}
}
}
}
This is a typical selection structure. The first Boolean expression is true or false to determine which part of the code to execute. Generally, if and else will be used together, therefore, this is very important and must be thoroughly understood.
 
3. Loop Structure:
For the loop structure, there are several forms such as while, do... while, and for. So there is no much explanation here, and no instance is needed to identify it.
 
Introduction to object-oriented programming;
 
Its concept or basic idea is to use basic concepts such as class, object, inheritance, encapsulation, and message for program design. It constructs a software system based on objective things (objects) in the real world, and tries its best to use human natural thinking methods in system construction, emphasize that we can directly think about problems and understand problems based on things in the real world, and mark them as classes in the system based on the essential characteristics of these things, as the basic unit of the system (instead of using other processes that are closely related to things in the real world and have no corresponding relationships), the system can be directly mapped to the objective world, and maintain the original appearance of things and their relationships in the objective world.
Author: "Li Yuan Cao"

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.