In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to analyze the similarities and differences between C language and Java in process control. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Similarities and differences between C and Java in process Control
Process programming (C) must first define the functions to be realized, and then set them as the steps necessary to realize them. All of a sudden, this is the process. Coding code is equivalent to decomposing these steps in real time, so that each step corresponds directly to a line of code. In order to realize the limited reuse, the code is woven into processes or functions. You can weave another group into a process or function every time you send a code that is used in reverse. This formula is suitable for some questions, which is that if the sequence reaches a certain degree, the debugging and maintenance of the sequence will become very difficult, and the process programming (language) is not suitable. Therefore, the programming method of face-to-face object and the language of face-to-face object (Java) have become the main stream of programming. The root cause of the locality of process programming lies in the difference between him and the real world model. In the model of the real world, the real body is the constituent unit of the basis, and the real body has property and behavior, which are muddy. Contrary to the procedural language, the language facing the object considers the difference between the two. In the face of the image, the first consideration is which physical bodies are needed and what kind of behavior these physical bodies have. The real body is the object, and the action is based on the reflection of some elimination of interest.
Flow control system is of paramount importance to any programming language. He mentions the basic hand segment of controlling the sequence step, which is the core part of the process. It can be said that without the control of flow, there will be no program planning words, because there is no kind of sequence that only holds the line sentence sequence linearly. In the program, it is necessary to communicate with the user, to determine the row sequence according to the user's input, to follow the loop, and so on, all of which are indispensable to the flow program control system.
The flow control system of Java includes: piece statement IF; loop sentence while,do while, for; switch sentence switch,case,break; transfer sentence break,continue,label; return sentence return and compound sentence. Maybe you will think that these sentences are the same as C, there is no difference. Yes, the sentence is the same, but it is still stored in a different area. next, let's see where the difference is.
Piece statement if-else
The piece statement is the most basic flow-controlled sentence in the sequence planning sentence. Almost any program order design statement uses the IF off key word, so the piece statement is also called IF sentence. The article sentence is divided into the simple single sentence and the compound sentence, for example, the branch of the piece sentence includes the piece sentence, that is, it is called the compound piece sentence, or the nested piece sentence; otherwise, it is called the simple single sentence.
Usage: if (boolean) statement1 else statement2
Different: the expression of the item in the Java branch statement must be Boolean, not numerical. Instead of putting numerical data directly like C, you should replace it with a closed table.
Class sample1
{
Public static void main (String args [])
{
Char Ch
System.Out.println ("Please enter a number 1-3:")
Ch= (char) System.in.read ()
If (Ch==-1)
System.out.println ("nNo character entered.")
Else if (Ch=='1')
System.out.println ("nYou have entered a 1.")
Else if (Ch=='2')
System.out.println ("nYou have entered a 2.")
Else if (Ch=='3')
System.out.println ("nYou have entered a 3.")
Else System.out.println
"nYou have entered a wrong number.")
}
}
Java also mentions three different loop sentences.
The function of the while while sentence of the loop sentence is that when the clause is formed, the repetition of the line clause is repeated, and the number of repetition depends on the state of the clause. The usage of while sentence
While (boolean_expression)
{
Statements
}
Loop sentence do
If you need to follow the ring statement at least once, you can use the do---while sentence. Do-while sentence is a variation of the while sentence. The usage is:
Do
{
Statements
} while (boolean_expression)
The main body of the difference between Java and C loop sentences is now in the item expression. The item expression in C is much more flexible than that of Java, which can be taken as any integer expression. Java must be Boolean expression.
Loop sentence for
For sentence is the most accurate loop sentence, almost all the high-level programming sentences offer similar loop sentences, and it is also a kind of loop construction with the strongest function. The function of for sentence is to follow a paragraph of sentences in a loop. Until a piece is false, its structure is:
For (expresson1;expression2;expression3)
{
Statements
}
Class sample2
{
Public static void main (String args [])
{
Char Ch
Int iTunes 0
Boolean test=True
While (test)
{
ITunes 1
System.Out.println ("nThe line d", I ")
If (Illumination 10) test=false
}
For (Illustrated 20 position I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.