2016-06-28
1 Blank separator space, tab, line feed
2 keywords cannot be used for variable names, class names, object names, method names, and so on.
access Control private protected public
class, method, and variable modifier abstract class extends final implements interface native new static strictfp synchronized transient VO Latile
Program Control break continue return does while if-else for instanceof switch case default
error handling Try catch throw throws
Packages related Import Package
base Type boolean byte char double float int long short null true false
(Null True false these three are actually not keywords, they are separate identity types)
variable reference super this void
reserved word goto const
3 identifiers
Identifiers are the names of classes, methods, and variables.
Naming rules:
Can contain numbers, letters, underscores, dollar sign $, but cannot begin with a number.
Case sensitive
Keyword is not used as an identifier
Helloword compliant
Goto does not match
Agoto compliant
123goto Non-compliant
4 Notes
Single line Comment //The content here is a comment
This is the second line of comments
This is the third line of comments
Comment Block /* .... */
Document comments
/** This document comment, can be wrapped
Document comments allow the information about the program to be embedded inside the program, and we can use the Javadoc tool
To extract this information and form a help document
*/
5 separators
() parentheses define the parameter table of the method. Condition and, in a circular statement, a condition definition. Defines the precedence of an expression.
{} curly braces initialize the array, defining the program block, class, method.
[] square brackets DECLARE array types
; A semicolon indicates the end of a statement
, a comma variable declaration is used to separate multiple variables int i;int j;int i,j;
. Points are used for packages and sub-packages or classes, objects, and variables or methods to separate System.out.println ("Hello world!");
In addition to the comments can appear in Chinese, the other places are English, all kinds of punctuation must also be in English state.
Resources
[1] Java Easy Start Classic tutorial "full version"
Java section 4th basic elements of Java