5, Java keywords and identifiers

Identifier: Java character sequence used when a variety of variables, methods and classes and other factors designation as an identifier. (Who named the place they can call identifier, follow the rules for identifiers)
the Java naming convention:
1, identified by the letters, underscore "_" dollar sign "$" or numbers;
2, should identifier underlined letter beginning, the dollar sign;
3, Java identifiers are case sensitive, unlimited length;
4, select Java identifier should be noted that "knowingly intended to see" and not with the Java language keywords the same name (the convention)

Legal identifier
the HelloWorld
DataClass
983
$ bS5_c7

Not legal identifier
class
DataClass #
98.3
Hell World

Keywords: Java some special meaning given, with a string special purposes are called keywords (keyword) (most editors will be marked with a special key way)
all the Java keywords are lowercase English
goto and const though never used, but also retained as Java keywords

 

category Keyword Explanation
Access control private private
protected under protection
public public
Class, method and variable modifiers abstract Abstract statement
class class
extends Yun expansion, succession
final The final value can not be changed
implements Implement (Interface)
interface interface
native Local, native method (non-Java implementation)
new New, created
static Static state
strictfp Strict, precise
synchronized Threads, synchronization
transient short
volatile Volatile
Program control statements break Out of the loop
case Define a value for switch selection
continue carry on
default default
do run
else otherwise
for cycle
if in case
instanceof Examples
return return
switch Execution based on the value selected
while cycle
Error Handling assert Whether the assertion expression is true
catch Catch an Exception
finally There are no exceptions to perform
throw Throw an exception object
throws Declare an exception might be thrown
try Catch the exception
Package Dependencies import Introduced
package package
basic type boolean Boolean
byte Byte
char Character
double Double-precision floating point
float Single-precision floating point
int Integer
long Long integer
short Short integer
null air
Variable reference super The parent class, the superclass
this This class
void No return value
Reserved Keywords goto Keyword, but you can not use
const Keyword, but you can not use

 

Java constants: string identifier, to distinguish between different types of data.
A constant integer: 123
real constant: 3.14
character constant: 'a'
logical constants: true, false
string constants: "HelloWord"
Note: distinguishing character constants and string literals;
Note: "constant" term will be used; Also other contexts immutable value of the variable, see the final keyword

 

Guess you like

Origin www.cnblogs.com/hlc-123/p/10994045.html
Recommended