JAVA Quick Reference
Author: Jialong He
Jialong_he@bigfoot.comhttp://www.bigfoot.com/~jialong_he
Simple Data Types
byte
8
int
32
-2,147,483,648.. 2,147,483,647
-9,223,372,036,854,775,808..9,223,372,036,854,775,807
16
Complete Unicode Character Set
declare an integer array and allocate100 elements of memory.
int
array_name
[ ] =
new int
[100];
int
array_name
[ ] = {1, 2, 3, 4};
declare and allocate an integer array inone statement.
int
array_name
[] =
newint
[10][20];
multidimensional array.
null
for reference type (class, array).
Class
{public|final|abstract} class name{ [class_variable_declarations]public static void main{String[] args) {statements}[methods]}this, super
addition, subtraction, multiplication, divisionmodulus, increment, decrement.
equal, not equal, greater, less,greater or equal, less or equal.
Logical Operators
&, |, !, ^, ||, &&,
AND, OR, NOT, XOR, short-circuit OR, AND
Bitwise Operators
&, |, ~, ^,
AND, OR, NOT, XORshift right, shift right zero fill, shift left.
Comments
// rest of line /* multiline comment */ /** documentation comment */
Compile and Run
javac nameOfFile.java java nameOfFileCLASSPATH must set correctly.The name of the file has to match exactly the name of the class.
Flow Control
if (Boolean-expression) statement1; [ else statement2; ]while loop[initialization]while (termination-clause) {body;[iteration;]}do while loopdo {body;[iteration;]} while (termination-clause);for loopfor (initialization; termination-clause; iteration)body;Program Structureclass className {public static void main (String args[ ]) {statements;}method definition1…method definitionN}
java.applet
Provides the classes necessary to create an appletand the classes an applet uses to communicate withits applet context.
java.awt
Contains all of the classes for creating userinterfaces and for painting graphics and images.
java.awt.color
Provides classes for color spaces.
java.awt.datatransfer
Provides interfaces and classes for transferring databetween and within applications.
java.awt.dnd
Drag and Drop is a direct manipulation gesturefound in many Graphical User Interface systemsthat provides a mechanism to transfer informationbetween two entities logically associated withpresentation elements in the GUI.
java.awt.event
Provides interfaces and classes for dealing withdifferent types of events fired by AWTcomponents.
Provides classes and interface relating to fonts.
java.awt.geom
Provides the Java 2D classes for defining andperforming operations on objects related to two-dimensional geometry.
Provides classes and interfaces for the input methodframework.
java.awt.im.spi
Provides interfaces that enable the development of input methods that can be used with any Javaruntime environment.
java.awt.image
Provides classes for creating and modifyingimages.
java.awt.image.renderable
Provides classes and interfaces for producingrendering-independent images.
java.awt.print
Provides classes and interfaces for a generalprinting API.
Contains classes related to developing
beans
--components based on the JavaBeans
TM
architecture.
Leave a Comment