📄 java3.txt
字号:
arg << arg Left-shift
arg >> arg Right-shift
arg >>> arg Zero-fill right-shift
~ arg Complement
(type)thing Casting
arg instanceof class Instance of
test ? trueOp : falseOp Ternary (if) operator
Objects
new class() Creates new instance
new class(arg,arg,arg...) New instance with
parameters
object.variable Instance variable
object.classvar Class variable
Class.classvar Class variable
object.method() Instance method (no
args)
object.method(arg,arg,arg...) Instance method
object.classmethod() Class method (no args)
object.classmethod(arg,arg,arg...) Class method
Class.classmethod() Class method (no args)
Class.classmethod(arg,arg,arg...) Class method
Arrays
Note
The brackets in this section are parts of the array creation
or access statements. They do not denote optional parts as
they do in other parts of this appendix.
Type varname[] Array variable
type[] varname Array variable
new type[numElements] New array object
array[index] Element access
array.length Length of array
Loops and Conditionals
if ( test) block Conditional
if ( test ) block else block Conditional with else
switch (test) { switch (only with integer
case value : statements or char types)
case value : statements
...
default : statement
}
for (initializer; test; for loop
change ) block
while ( test ) block while loop
do block do loop
while (test)
break [ label ] break from loop or switch
continue [ label ] continue loop
label: Labeled loop
Class Definitions
class classname block Simple class definition
Any of the following optional modifiers can be added to the
class definition:
[ final ] class classname Cannot be subclassed
block
[ abstract ] class classname Cannot be instantiated
block
[ public ] class classname Accessible outside package
block
class classname [ extends Define superclass
Superclass ] block
class classname [ implements Implement one or more
interfaces ] block interfaces
Method and Constructor Definitions
The basic method looks like this, where returnType is a type
name, a class name, or void.
ReturnType methodName() block Basic method
returnType methodName(parameter, Method with parameters
parameter, ...) block
Method parameters look like this:
type parameterName
Method variations can include any of the following optional
keywords:
[ abstract ] returnType Abstract method
methodName() block
[ static ] returnType Class method
methodName() block
[ native ] returnType Native method
methodName() block
[ final ] returnType final method
methodName() block
[ synchronized ] returnType Thread lock before
methodName() block executing
[ public | private | protected Access control
] returnType methodName()
Constructors look like this:
classname() block Basic constructor
classname(parameter, parameter, Constructor with
parameter...) block parameters
[ public | private | protected] Access control
classname() block
In the method/constructor body you can use these references and
methods:
this Refers to current object
super Refers to superclass
super.methodName() Calls a superclass's method
this(...) Calls class's constructor
super(...) Calls superclass's constructor
return [ value ] Returns a value
Packages, Interfaces, and Importing
import package.className Imports specific class name
import package.* Imports all public classes in
package
package packagename Classes in this file belong to this
package
interface interfaceName [ extends anotherInterface ] block
[ public ] interface interfaceName block
[ abstract ] interface interfaceName block
Exceptions and Guarding
synchronized ( object ) block Waits for lock on object
try block Guarded statements
catch ( exception ) block Executed if exception is thrown
[ finally block ] Cleanup code
try block Same as previous example
[ catch ( exception ) block ] (can use optional catch or
finally block finally, or both)
----------
appendix B
Class Hierarchy Diagrams
CONTENTS
* About These Diagrams
About These Diagrams
The diagrams in this appendix are class hierarchy diagrams for
the package java and for all the subpackages recursively below
it in the Java 1.0 binary release.
Each page contains the class hierarchy for one package (or a
subtree of a particularly large package) with all its interfaces
included, and each class in this tree is shown attached to its
superclasses, even if they are on another page. A detailed key
is located on the first page of this appendix.
I supplemented the API documentation by looking through all the
source files to find all the (missing) package classes and their
relationships.
I've heard there are various programs that auto-layout
hierarchies for you, but I did these the old-fashioned way (in
other words, I earned it, as J.H. used to say). One nice side
effect is that these diagrams should be more readable than a
computer would produce, though you will have to live with my
aesthetic choices. I chose, for example, to attach lines through
the center of each class node, something which I think looks and
feels better overall but which on occasion can be a little
confusing. Follow lines through the center of the classes (not
at the corners, nor along any line not passing through the
center) to connect the dots mentally.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -