JAVA Quick Reference
[Link]
+, -, *, / %, ++, --
addition, subtraction, multiplication, division modulus, increment, decrement.
abstract case const else float if int null static throw var
boolean cast continue extends for implements interface operator super throws void
break catch default false future import long outer rest switch transient volatile
byte char do final generic inner native package return true while
byvalue class double finally goto instanceof new private short try
Relational Operators
==, !=, >, <, >=, <= equal, not equal, greater, less, greater or equal, less or equal.
Simple Data Types
byte short int long float double char Boolean decare a variable: type identifier [= value]; 8 16 32 64 32 64 16 -128..127 -32,768..32,767 -2,147,483,648.. 2,147,483,647 -9,223,372,036,854,775,808.. 9,223,372,036,854,775,807 3.4e-0.38.. 3.4e+0.38 1.7e-308.. 1.7e+308 Complete Unicode Character Set true, false
Logical Operators
&, |, !, ^, ||, &&, AND, OR, NOT, XOR, short -circuit OR, AND
Bitwise Operators
&, |, ~, ^, >>, >>>, << AND, OR, NOT, XOR shift right, shift right zero fill, shift left.
protected public
synchronized this
Comments
// rest of line /* multiline comment */ /** documentation comment */
Java packages
[Link]
Compile and Run
javac [Link] java nameOfFile
Arrays
int array_name[ ]; array_name=new int[100 ]; declare an integer array and allocate 100 elements of memory. int array_name[ ] = new int [ declare and allocate an integer array in 100]; one statement. int array_name [ ] = {1, 2, 3, 4}; int array_name[] = new int[10][20]; null multidimensional array. for reference type (class, array).
CLASSPATH must set correctly. The name of the file has to match exactly the name of the class.
Flow Control
Class
{public|final|abstract} class name { [class_variable_declarations] public static void main{String[] args) {statements} [methods] } this, super
if (Boolean-expression) statement1; [ else statement2; ] while loop [initialization] while (termination-clause) { body; [iteration;] } do while loop do { body; [iteration;] } while (termination-clause); for loop for (initialization; termination-clause; iteration) body;
Fa
h a l
h c e
l o n
y g o
Provides the classes necessary to create an applet and the classes an applet uses to communicate with its applet context. Contains all of the classes for creating user interfaces and for painting graphics and images. Provides classes for color spaces.
[Link] [Link]
[Link] Provides interfaces and classes for transferring data between and within applications. r [Link] Drag and Drop is a direct manipulation gesture found in many Graphical User Interface systems that provides a mechanism to transfer information between two entities logically associated with presentation elements in the GUI. Provides interfaces and classes for dealing with different types of events fired by AWT components. Provides classes and interface relating to fonts. Provides the Java 2D classes for defining and performing operations on objects related to twodimensional geometry. Provides classes and interfaces for the input method framework. Provides interfaces that enable the development of input methods that can be used with any Java runtime environment. Provides classes for creating and modifying images.
[Link]
[Link] [Link]
[Link] [Link]
Methods
{public | private } [static] {type | void} name(arg, ..., arg ) {statements}
Variable
{public | private } [static] type name [= expression];
Program Structure class className { public static void main (String args[ ]) { statements; } method definition1 method definitionN }
[Link]
[Link] Provides classes and interfaces for producing rendering-independent images. erable [Link] Provides classes and interfaces for a general printing API. Contains classes related to developing beans -components based on the JavaBeansTM architecture.
Arithmetic Operators
Key words
[Link]
[Link] Provides classes and interfaces relating to bean context. ext [Link] [Link] [Link] Provides for system input and output through data streams, serialization and the file system. Provides classes that are fundamental to the design of the Java programming language. Provides reference-object classes, which support a limited degree of interaction with the garbage collector. Provides classes and interfaces for obtaining reflective information about classes and objects. Provides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitraryprecision decimal arithmetic (BigDecimal). Provides the classes for implementing networking applications. Defines buffers, which are containers for data, and provides an overview of the other NIO packages. Defines channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets; defines selectors, for multiplexed, non-blocking I/O operations. [Link] [Link] [Link] [Link]
Signature Algorithm) keys as defined in NIST's FIPS-186. Provides classes and interfaces for key specifications and algorithm parameter specifications. Provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java TM programming language. Provides classes and interfaces for handling text, dates, numbers, and messages in a manner independent of natural languages. Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array). Provides classes for reading and writing the JAR (Java ARchive) file format, which is based on the standard ZIP file format with an optional manifest file. Provides the classes and interfaces of the Java platform's core logging facilities. This package allows applications to store and retrieve user and system preference and configuration data. Classes for matching character sequences against patterns specified by regular expressions. Provides classes for reading and writing the standard ZIP and GZIP file formats. [Link] m [Link]
the plug-in interfaces for readers, writers, transcoders, and streams, and a runtime registry. A package of the Java Image I/O API dealing with low-level I/O from files and streams. Provides the classes and interfaces for accessing naming services.
[Link]
[Link] Extends the [Link] package to provide functionality for accessing directory services. ory [Link] Provides support for event notification when accessing naming and directory services. [Link] [Link] Provides support for LDAPv3 extended operations and controls. Provides the means for dynamically plugging in support for accessing naming and directory services through the [Link] and related packages. Provides classes for networking applications. Provides classes for the secure socket package. Provides the principal classes and interfaces for the JavaTM Print Service API.
[Link]
[Link] [Link]
[Link] [Link] [Link]
[Link]
[Link] [Link] [Link]
[Link] Service-provider classes for the [Link] package. [Link] [Link] [Link] [Link] [Link] [Link] [Link] [Link] [Link] Defines charsets, decoders, and encoders, for translating between bytes and Unicode characters. Service-provider classes for the [Link] package. Provides the RMI package. Provides support for RMI Object Activation. Provides classes and interface for RMI distributed garbage-collection (DGC). Provides a class and two interfaces for the RMI registry. Provides classes and interfaces for supporting the server side of RMI. Provides the classes and interfaces for the security framework. The classes and interfaces in this package have been superseded by classes in the [Link] package. Provides classes and interfaces for parsing and managing certificates, certificate revocation lists (CRLs), and certification paths.
[Link] [Link]
h Java extension packages a l a F
[Link] [Link] [Link]
h c e
l o n
y g o
TM
[Link] Provides classes and interfaces that describe the types of JavaTM Print Service attributes and how they can be collected into attribute sets. [Link] Package [Link] contains classes for specific printing attributes. .standard [Link] [Link] [Link] [Link] Package [Link] contains event classes and listener interfaces. Contains user APIs for RMI-IIOP. Contains portability APIs for RMI-IIOP. This package provides a framework for authentication and authorization.
Defines a contract between user-interface components and an assistive technology that provides access to those components. Provides the classes and interfaces for cryptographic operations.
[Link] Provides interfaces for Diffie-Hellman keys as defined in RSA Laboratories' PKCS #3. ces Provides classes and interfaces for key specifications and algorithm parameter specifications. The main package of the Java Image I/O API.
[Link].c This package provides the classes necessary for services to interact with applications in order to allback retrieve information (authentication data including usernames or passwords, for example) or to display information (error and warning messages, for example). [Link]. This package contains utility classes related to the Kerberos network authentication protocol. kerberos [Link].l This package provides a pluggable authentication framework. ogin [Link].s This package provides the interface to be used for implementing pluggable authentication modules. pi [Link]. This package contains the classes that should be used to store X500 Principal and X500 Private x500 Crendentials in a Subject. [Link] [Link] Provides classes for public key certificates. Provides interfaces and classes for I/O, sequencing, and synthesis of MIDI (Musical Instrument Digital Interface) data.
[Link]
[Link]
[Link] A package of the Java Image I/O API dealing with synchronous notification of events during the reading and writing of images. [Link] A package of the Java Image I/O API dealing with reading and writing metadata. ata [Link] Classes supporting the built -in JPEG plug-in. [Link] [Link] A package of the Java Image I/O API containing
[Link] Provides interfaces for generating RSA (Rivest, Shamir and Adleman AsymmetricCipher ces algorithm) keys as defined in the RSA Laboratory Technical Note PKCS#1, and DSA (Digital
[Link] Supplies interfaces for service providers to implement when offering new MIDI devices, MIDI file readers and writers, or sound bank readers. [Link] Provides interfaces and classes for capture, processing, and playback of sampled audio data. d [Link] Supplies abstract classes for service providers to subclass when offering new audio devices, sound [Link] file readers and writers, or audio format converters. [Link] Provides the API for server side data source access and processing from the JavaTM programming language. Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms. [Link]
which allows the transaction manager to enlist and delist resource objects (supplied by the resource manager driver) in JTA transactions. Provides classes allowing the processing of XML documents.
[Link] This package defines the generic APIs for processing transformation instructions, and performing a transformation from source to result. [Link] This package implements DOM-specific transformation APIs. .dom [Link] This package implements SAX2-specific transformation APIs. .sax [Link] This package implements stream- and URIspecific transformation APIs. .stream
[Link]
[Link] Provides classes and interface for drawing specialized borders around a Swing component. [Link] ooser [Link] Contains classes and interfaces used by the JColorChooser component. Provides for events fired by Swing components.
[Link] Contains classes and interfaces used by the JFileChooser component. ser [Link] Provides one interface and many abstract classes that Swing uses to provide its pluggable look-andfeel capabilities.
[Link] Provides user interface objects built according to the Basic look and feel. ic [Link] Provides user interface objects built according to the Java look and feel (once codenamed Metal), al which is the default look and feel. [Link] Provides user interface objects that combine two or more look and feels. ti [Link] [Link] Provides classes and interfaces for dealing with [Link]. Provides classes and interfaces that deal with editable and noneditable text components.
Fa
h a l
h c e
l o n
y g o
[Link] Provides the class HTMLEditorKit and supporting classes for creating HTML text editors. l [Link] Provides the default HTML parser, along with support classes. [Link] [Link] [Link] [Link] [Link] Provides a class (RTFEditorKit) for creating RichText-Format text editors. Provides classes and interfaces for dealing with [Link]. Allows developers to provide support for undo/redo in applications such as text editors. Contains three exceptions thrown by the ORB machinery during unmarshalling.
[Link] Provides the API that defines the contract between the transaction manager and the resource manager,