Java For Dummies Quick Reference3 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6
At a glance
Powered by AI
The document provides an overview of Java programming concepts and tools, including the Java language basics, common classes, file and network input/output, and the Swing GUI toolkit.

The document is divided into 5 main parts which cover Java language tools, Java language basics, basic Java classes, file and network I/O, and Swing.

The javac command is used for compiling Java source code and the java command is used for running compiled Java programs. The javap command provides information about Java class files.

Contents at a Glance

Part 1: Java Language Tools ............................................................ 5


Part 2: Java Language Basics......................................................... 17

AL

Part 3: Basic Java Classes .............................................................. 97

RI

Part 4: File and Network I/O........................................................ 157

TE

Part 5: Swing................................................................................. 205

CO

PY

RI

GH

TE

MA

Index ............................................................................................. 265

Table of Contents
Introduction.................................................. 1
Introduction .......................................................................................1
About Java For Dummies Quick Reference ....................................1
Foolish Assumptions ........................................................................1
Conventions Used in This Book ......................................................2
How This Book Is Organized............................................................2
Icons Used in This Book ...................................................................3
Where to Go from Here ....................................................................4

Part 1: Java Language Tools .......................... 5


Downloading and Installing the Java Development Kit ................6
JDK Folder Structure ........................................................................7
Setting the Path for Java ..................................................................8
java Command ...................................................................................9
javac Command ...............................................................................10
javap Command...............................................................................13
jar Command ...................................................................................14

Part 2: Java Language Basics...................... 17


& and && Operators .......................................................................18
| and || Operators..........................................................................18
! Operator .........................................................................................18
Abstract Class..................................................................................18
And Operators (& and &&) ............................................................20
Anonymous Class ............................................................................20
Arrays ...............................................................................................21
Assignment Statements ..................................................................25
Blocks ...............................................................................................27
boolean Data Type ..........................................................................28
Boolean Expressions ......................................................................28
Boolean Operators ..........................................................................30
break Statement ..............................................................................30
byte Data Type ................................................................................31
Casting ..............................................................................................31
char Data Type ................................................................................31
Checked Exceptions........................................................................32
Class Declaration ............................................................................33
Class Variables ................................................................................35
Comments ........................................................................................36
Concatenating Strings.....................................................................37
Constants .........................................................................................38
Constructor ......................................................................................38
continue Statement .........................................................................40

Java For Dummies Quick Reference


Data Types .......................................................................................40
Decrement Operator .......................................................................41
do...while Statement .......................................................................41
double Data Type ............................................................................42
Escape Sequences ...........................................................................43
Exception Class ...............................................................................43
Exceptions........................................................................................44
extends Keyword ............................................................................45
Fields.................................................................................................46
final Class .........................................................................................46
final Method .....................................................................................47
final Variables ..................................................................................48
float Data Type ................................................................................48
Floating-point Data Types ..............................................................48
for Statement ...................................................................................49
Generic Class ...................................................................................51
Identifiers .........................................................................................52
if Statement ......................................................................................53
implements Keyword ......................................................................55
import Statement ............................................................................55
Increment and Decrement Operators...........................................56
Inheritance .......................................................................................57
Inner Class........................................................................................59
Initializer ..........................................................................................59
Instance Variables ...........................................................................61
int Data Type ...................................................................................61
Integer Data Types ..........................................................................61
Interface ...........................................................................................62
Keywords .........................................................................................64
Local Variables ................................................................................65
Logical Operators............................................................................66
long Data Type.................................................................................67
Main Method ....................................................................................68
Method .............................................................................................68
Not Operator (!) ...............................................................................70
Object-Oriented Programming ......................................................70
Operators .........................................................................................73
Or Operators (| and ||) .................................................................75
Package Statement ..........................................................................75
Parsing Strings .................................................................................76
Polymorphism .................................................................................77
Primitive Data Types ......................................................................78
private Keyword ..............................................................................79
protected Keyword .........................................................................79
public Keyword ...............................................................................79
Recursion .........................................................................................79
Reference Types ..............................................................................80
Scope ................................................................................................81
Shadowing ........................................................................................82

Table of Contents

xi

short Data Type ...............................................................................83


Statements .......................................................................................83
static Keyword.................................................................................84
String Data Type ..............................................................................85
switch Statement .............................................................................86
super Keyword ................................................................................88
this Keyword....................................................................................89
throw Statement ..............................................................................90
throws Keyword ..............................................................................91
try Statement ...................................................................................91
Variables ..........................................................................................94
while Statement ...............................................................................94
White Space .....................................................................................95

Part 3: Basic Java Classes ........................... 97


ArrayList Class ................................................................................98
Arrays Class ...................................................................................103
Class Class .....................................................................................108
Exception Class .............................................................................110
Iterable Interface ...........................................................................111
Iterator Interface ...........................................................................111
LinkedList Class ............................................................................112
Matcher Class ................................................................................121
Math Class ......................................................................................122
NumberFormat Class ....................................................................126
Object Class ...................................................................................128
Pattern Class ..................................................................................134
Random Numbers .........................................................................135
Regular Expressions .....................................................................135
Runnable Interface ........................................................................141
String Class ....................................................................................142
StringBuffer Class ..........................................................................149
StringBuilder Class........................................................................149
Thread Class ..................................................................................152

Part 4: File and Network I/O ..................... 157


BufferedInputStream Class ..........................................................158
BufferedOutputStream Class .......................................................159
BufferedReader Class ...................................................................160
BufferedWriter Class.....................................................................162
DataInputStream Class .................................................................162
DataOutputStream Class ..............................................................165
DirectoryStream Class ..................................................................168
InputStream Class .........................................................................169
File Class.........................................................................................169
FileInputStream Class ...................................................................175
FileOutputStream Class ................................................................176
FileReader Class ............................................................................178

xii

Java For Dummies Quick Reference


Files Class .......................................................................................179
FileVisitor Interface.......................................................................182
FileVisitResult Enum .....................................................................183
FileWriter Class .............................................................................183
InetAddress Class..........................................................................184
OutputStream Class ......................................................................186
Path Interface ................................................................................186
Paths Class .....................................................................................188
PrintStream Class ..........................................................................188
PrintWriter Class ...........................................................................190
Reader Class ..................................................................................192
Scanner Class.................................................................................192
ServerSocket Class ........................................................................195
SimpleFileVisitor Class .................................................................196
Socket Class ...................................................................................198
Streams (Overview) ......................................................................201
System.err ......................................................................................202
System.out .....................................................................................203
Writer Class ...................................................................................203

Part V: Swing ........................................... 205


ActionEvent Class .........................................................................206
ActionListener Interface ...............................................................207
BorderFactory Class .....................................................................207
ButtonGroup Class ........................................................................209
DefaultListModel Class .................................................................211
Event Handling ..............................................................................213
FileFilter Class ...............................................................................215
ItemEvent Class .............................................................................217
ItemListener Interface ..................................................................219
JButton Class .................................................................................220
JCheckBox Class............................................................................222
JFileChooser Class ........................................................................225
JComboBox Class ..........................................................................230
JFrame Class ..................................................................................235
JLabel Class....................................................................................237
JList Class.......................................................................................239
JOptionPane Class ........................................................................243
JPanel Class ...................................................................................246
JRadioButton Class .......................................................................248
JScrollPane Class...........................................................................250
JSlider Class ...................................................................................252
JSpinner Class................................................................................255
JTextArea Class .............................................................................257
JTextField Class .............................................................................260
SpinnerListModel Class ................................................................262
SpinnerNumberModel Class ........................................................263

Index........................................................ 265

You might also like