First, the Java keyword
The Java keyword is a word that is given a special meaning in the Java language.
A) keywords to define the data type
class interface byte short int longfloat double char boolean void
b) keywords to define data type values
Nullturefalse
c) keywords to define Process Control
Ifelseswitchcasedefaultwhiledoforbreakcontinuereturn
d) Keywords used to define access rights
Publicprotectedprivete
e) Modifier keywords that define classes, functions, and variables
Abstractfinalstaticsynchronized
f) Keywords for the relationship between classes and classes
Extendsimplements
g) To establish an instance to determine the instance keyword
Newthis superinstaceof
h) for handling exception keywords
Trycatchfinallythrowthrows
i) keywords for the package
Packageimport
j) Other Keywords
Nativestrictfptransientvolatieassert
Note: The Java keyword Military lowercase, some upper caps are due to WPS. Java also has two reserved words: Goto and const
Second, Java identifiers
All components of Java require a name. Class names, variable names, and method names are called identifiers.
1. With regard to Java identifiers, the following points need to be noted:
- All identifiers should start with a letter (A-Z or a-Z), a dollar symbol ($), or an underscore (_).
- Can be a combination of any character after the first character
- Keyword cannot be used as an identifier
- Identifiers are case-sensitive
- You can use Chinese characters
- Cannot start with a number
Example:
Examples of legal identifiers: Age, $salary, _value, __1_value
Examples of illegal identifiers: 123abc,-salary
2. Naming conventions for identifiers
- Identifiers to see the meaning of the name
- Adopt a canonical naming convention. such as: Hump Name method
Third, Java annotations
Comments are text that is used for annotation descriptions and for interpreting programs. It helps to improve the reading of the code. There are three types of comments in Java, as follows:
A) Single-line comment://.....
The single-line comment only notes one line, ending at the enter of the line.
Please enter your name
System.out.println ("Please enter your. Name here:"););
b) Multi-line Comment:/* ... */
Multiline comments start with/* and end with a multiline annotation with the contents of */* and/*.
/* SYSTEM.OUT.PRINTLN ("Please enter your:"); int age = In.nextint (); System.out.println ("Please enter your gender here:"); String gender = In.next (); */
c) Documentation notes:/** ... */
The main purpose of the document annotation is to describe the source program that we write, which can be extracted from a tool in Java and generated by a document. (Tool for JavaDoc.exe)
The Javadoc.exe tool extracts all the document comments from the Java source code and then generates a Web page file that includes the source code and documentation comments. That is to generate a program specification, this is to facilitate the development and maintenance of two times, this is for programmers to see.
/** * Calculate the current interest rate * @param Year * The number of years * @param money * deposited in the principal * @return * * *
d) The role of annotations:
- Annotations can be used to debug code, to locate and narrow the range of errors
- Annotated source code to improve the readability of the program, improve the maintenance of the program
Attention:
The comments section is in a file that is not written to the bytecode.
Expand Knowledge Points:
1. Hump Naming method:
A) Variable and method name: The first word is all lowercase, the first letter of the following word is capitalized
b) class name and interface name: Capitalize the first letter of each word
c) Constants: Constants all letters of each word are capitalized, and multiple words are separated by _
2. Markup for document annotations
@author author @param The name of the input parameter description @return output parameter Description @since JDK version @version version number @see link Destination @throws exception @deprecated explanation @link Link Address
Blog: http://www.cnblogs.com/cenzhongman/p/6137351.html
Basic syntax for Java 1