Java programming those things 16 -- code framework, keywords and identifiers by Chen yuefeng from: http://blog.csdn.net/mailbomb
3.2 code framework"Rome is not built in one day", so it is unrealistic to learn just a few days of grammar or a week or two of grammar to be proficient in programming. In an extreme example, how many years have you studied English? Can you communicate with people and write articles fluently? Of course, in terms of program syntax, it is much easier than English. At the beginning of learning Java, it is impossible to clearly introduce all the syntaxes. However, if you need to correctly run the program, you must have a lot of syntax knowledge, in order to compile and execute your own code at the early stage of learning, a simple code framework is provided to facilitate your initial practice. The structure of the code framework is as follows: public class file name {public static void main (string [] ARGs) {your code} when using this code framework, you only need to replace the location of the "file name" with your own file name, and write your own code in the "your code" location. Example: public class Hello {public static void main (string [] ARGs) {system. out. println ("Hello world! ");} In the sample code, "file name" is replaced with hello, and "your code" is replaced with system. Out. println ("Hello World !");, In subsequent examples, the code snippets should be written in the "your code" position unless otherwise specified, and will not be specifically stated later.
3.3 keywordsA keyword (keyword), also known as a reserved word, is a word specified in the program code. That is to say, as long as the word appears inside the program code, the compiler considers it a fixed purpose. The keyword list and explanation are as follows, in the format of: keyword (Chinese interpretation): Abstract (abstract) continue (CONTINUE) for (when... New (new) Switch (conversion) assert (assert) default (default) if (IF) package (Package) synchronized (synchronous) Boolean (Boolean) Do (DO) goto (jump to) Private (private) This (this) Break (Interrupt) double (Double Precision) implements (Implementation) protected (protected) Throw (throw, verb) byte (byte) else (otherwise) Import (introduced) Public (public) throws (throw, prefix) Case (CASE) Enum (enumeration) instanceof (Yes... Return (return) transient (instantaneous) catch (capture) extends (inherited) int (integer) Short (short integer) Try (try) Char (character) final (final) interface (Interface) static (static) void (null) Class (class) Finally (final) Long (long integer) strictfp (precise floating point) volatile (variable) const (constant) float (single precision Floating Point) Native (local) Super (Super) while (when... Note: The usage of Goto and const is retained, and these two keywords are not used in the syntax. In actual learning, you must remember the meaning and spelling of keywords. Most of the subsequent grammar knowledge is composed of keywords and symbols. The meaning of keywords basically represents the purpose of this syntax format.
3.4 identifierIdentifier, that is, the identifier symbol, refers to the name specified by all users in the program, for example, the variable name, constant name, array name, method name, parameter name, class name, interface name, and object name involved in subsequent syntaxes. In fact, apart from some delimiters, such as spaces, Parentheses, and punctuation marks, there are only three types of names in the program: l keyword L system function names such as system. Out. println in system, out, And println. L for learners who are not good at English, the first and second types of identifiers need to be familiar with and remembered. The third type of names, that is, identifiers, can be set by the program developers themselves. Generally, to improve the readability of the program, the name of the general identifier is consistent with the role of the identifier. The naming rules of identifiers mainly have the following requirements: 1. They cannot be keywords. 2. They can only start with letters, underscores (_), and dollar signs ($, the identifier cannot start with a number. 3. It cannot contain special characters, such as spaces, Parentheses, and punctuation marks. Generally, identifiers are all letters, or a combination of letters and numbers.