Java Tips
 

By Heather MacKenzie

Object-Oriented Programming

Keywords

Constructors

Memory and Garbage Collection

Data Types and Values



Data Type


Range of Values
 


byte

-27.. 27-1

signed integer



short

-215.. 215-1

signed integer



int

-231.. 231-1

signed integer



long

-263.. 263-1

signed integer



float

32 bit

signed floating point



double

64 bit

signed floating point



char

16 bit

Unicode character



boolean

either true or false

 

Operators

Control Flow

Exceptions

Methods

Math and String Classes



Method call
Returns
ceil(9.01)

9.0

ceil(-0.1)

0.0

ceil(100)

100.0



Method call
Returns
round(9.01)

9

round(9.5)

10

round(-9.5)

-9

round(-0.1)

0

round(100)

100



Arguments


Results
(int ch) - works if you put a char in! Finds the first occurrence of this character
(int ch, int fromIndex) Finds the first occurrence of this character starting from fromIndex
(String substring) Finds the start of this substring
(String substring, int fromIndex) Finds the start of this substring searching from fromIndex



Arguments


Results
(int startIndex) Returns a substring starting with startIndex and extending to the end of the String
(int startIndex, int endIndex) Returns a substring starting with startIndex and extending to (but not including) endIndex

Input/Output

Threads

Graphical User Interfaces

Event Handling



Listener


Methods


ActionListener
actionPerformed


AdjustmentListener
adjustmentPerformed
ComponentListener

componentHidden

componentMoved

componentResized

componentShown



ContainerListener
componentAdded

componentRemoved


FocusListener
focusGained

focusLost


ItemListener
itemStateChanged


KeyListener

keyPressed

keyReleased

keyTyped



MouseListener

mouseClicked

mouseEntered

mouseExited

mousePressed

mouseReleased



MouseMotionListener
mouseDragged

mouseMoved


TextListener
textValueChanged


WindowListener

windowClosed

windowClosing

windowDeiconified

windowActivated

windowDeactivated

windowIconified

windowOpened

See pages 360-363 for Event classes.

Passing Arguments to Programs

Embedding Applets into Web Pages

Inner Classes

JAR Files

Serializing Objects

Reflection