Cover image for Murach's beginning Java 2
Title:
Murach's beginning Java 2
Author:
Steelman, Andrea, 1973-
Personal Author:
Publication Information:
Fresno, Calif. : Mike Murach, [2001]

©2001
Physical Description:
xviii, 712 pages : illustrations ; 26 cm + 1 computer optical disc (4 3/4 in.)
General Note:
"Includes versions 1.3 & 1.4."
Language:
English
ISBN:
9781890774127
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Item Holds
Searching...
QA76.73.J38 S84 2001 Book and Software Set Central Closed Stacks
Searching...

On Order

Summary

Summary

An exciting, new approach to Java instruction that includes the latest Java releases (1.3.1 and 1.4). In just twenty chapters, you grow from beginner to entry-level professional. Along the way, you learn how to develop GUIs with Swing components; how to work with files; how to use JDBC to work with databases; how to develop applets that are run from Internet browsers; how to work with threads; and much more. It's all there in the unique Murach style that has been training professional programmers for more than 25 years. Includes CD-Rom.


Table of Contents

Section 1 The essence of Java programming
Chapter 1 How to get started with Java
Introduction to Javap. 4
Toolkits and platformsp. 4
Java compared to C++p. 4
Applications, applets, and servletsp. 6
How Java compiles and interprets codep. 8
How to get Java on your systemp. 10
How to install the SDKp. 10
A summary of the directories and files of the SDKp. 12
How to configure Windows to work with the SDKp. 14
How to use Windows tools to work with Javap. 16
How to use Notepad to save and edit source codep. 16
How to use the DOS prompt to compile source codep. 18
How to use the DOS prompt to run an applicationp. 18
Common error messages and solutionsp. 20
Essential DOS skills for working with Javap. 22
How to use TextPad to work with Javap. 24
How to use TextPad to save and edit source codep. 24
How to use TextPad to compile source codep. 26
How to use TextPad to run an applicationp. 26
Introduction to Java IDEsp. 28
Why we don't recommend using an IDE when you're learning Javap. 28
Why we recommend using an IDE once you've mastered Javap. 28
Perspectivep. 30
Chapter 2 Java language essentials (part 1)
Basic coding skillsp. 36
How to code commentsp. 36
How to code statementsp. 36
How to create identifiersp. 38
How to declare a classp. 40
How to declare a main methodp. 42
How to work with the primitive data typesp. 44
The eight primitive data typesp. 44
How to initialize variablesp. 46
How to initialize constantsp. 46
How to code assignment statementsp. 48
How to code arithmetic expressionsp. 50
Four classes for working with datap. 52
How to use the String class to create a String objectp. 52
How to use two methods of the String classp. 54
How to join two or more stringsp. 54
How to use the Integer and Double classesp. 56
How to use two methods of the System.out object to print data to the consolep. 58
How to use the JOptionPane class for input and outputp. 62
How to import classesp. 62
How to use the JOptionPane class to get inputp. 64
How to use the System.exit method to end a JOptionPane threadp. 64
How to use two more methods of the JOptionPane classp. 66
How to code control statementsp. 68
How to code conditional expressionsp. 68
How to code if/else statementsp. 70
How to code while statementsp. 72
The Invoice applicationp. 74
The dialog boxes for the applicationp. 74
The code for the applicationp. 74
Perspectivep. 76
Chapter 3 Java language essentials (part 2)
Two more classes for working with numbersp. 80
How to use the Math classp. 80
How to use the NumberFormat classp. 82
How to use try/catch statementsp. 84
How to code try/catch statementsp. 84
How to use nested while loops to validate input datap. 86
How to create and use static methodsp. 88
How to create a static methodp. 88
How to use a static method to validate input datap. 90
Two more applicationsp. 92
The Future Value applicationp. 92
The Book Order applicationp. 96
How to use the documentation for the Java APIp. 100
How to install the API documentationp. 100
How to navigate the API documentationp. 102
Perspectivep. 104
Chapter 4 How to write object-oriented programs
An introduction to object-oriented programmingp. 108
How encapsulation worksp. 108
The relationship between a class and its objectsp. 110
How to code a class that defines an objectp. 112
The code of the Book classp. 112
How to code instance variablesp. 114
How to code constructorsp. 116
How to code methodsp. 118
How to create an object from a classp. 120
The code of the BookApp classp. 120
How to create an objectp. 122
How to call the methods of an objectp. 124
The object-oriented code of the Book Order applicationp. 126
The code of the BookOrder classp. 126
The code of the BookOrderApp classp. 128
The benefits and shortcomings of object-oriented programmingp. 128
How to create and use static fields and methodsp. 130
How to create static fields and methodsp. 130
How to call static fields and methodsp. 132
How to code a static initialization blockp. 134
When to use static fields and methodsp. 134
How to work with packagesp. 136
How to create and compile packagesp. 136
How to make packages available to other classesp. 138
How to use javadoc to document a classp. 140
How to add javadoc comments to a classp. 140
How to generate the documentation for a classp. 142
How to view the documentation for a classp. 142
Perspectivep. 144
Chapter 5 How to work with inheritance and interfaces
How to work with inheritancep. 150
An introduction to inheritancep. 150
How to code a class that inherits the BookOrder classp. 152
How to code a class that inherits the JFrame classp. 154
What you should know about polymorphismp. 154
How to work with the Object classp. 156
The methods of the Object classp. 156
How to cast objectsp. 158
How to override the toString methodp. 160
How to override the equals methodp. 162
How to use the Class class to get information about an Object objectp. 164
More skills for coding classes and methodsp. 166
How to code a method that throws an exceptionp. 166
How to work with abstract classes and methodsp. 168
How to work with final classes and methodsp. 170
How to work with access modifiersp. 172
How to use the this keywordp. 174
How primitive types and objects are passed to a methodp. 176
How to work with interfacesp. 180
An introduction to interfacesp. 180
How to code an interfacep. 182
How to implement an interfacep. 184
How to use an interface as an argumentp. 186
How to implement the Cloneable interfacep. 188
How to code classes that are closely relatedp. 190
How to code more than one class per filep. 190
An introduction to nested classesp. 192
Perspectivep. 194
Chapter 6 How to design and test object-oriented programs
An introduction to object-oriented designp. 198
A common architecture for object-oriented programsp. 198
How to work with class diagramsp. 200
A procedure for developing object-oriented programsp. 202
How to design the classes for a programp. 202
How to test an object-oriented programp. 204
How to code a main method that tests a classp. 204
When and how to code method stubsp. 206
The User Email applicationp. 208
The user interfacep. 208
The class diagramp. 208
The codep. 210
An introduction to the Book Maintenance applicationp. 216
The user interfacep. 216
The class diagramp. 216
Perspectivep. 218
Section 2 More Java essentials
Chapter 7 How to work with operators and dates
Operators, order of precedence, and associativityp. 224
A review of operatorsp. 224
How to work with the increment and decrement operatorsp. 226
How to work with the shortcut if/else operatorp. 228
How to work with the instanceof operatorp. 228
How to work with the bitwise and shift operatorsp. 230
How to work with order of precedence and associativityp. 232
How to work with dates and timesp. 234
How to use the GregorianCalendar class to set dates and timesp. 234
How to use the Calendar and GregorianCalendar fields and methodsp. 236
How to use the Date classp. 238
How to use the DateFormat class to format dates and timesp. 240
Code that adds the current date to the Book Order applicationp. 242
Perspectivep. 244
Chapter 8 How to code control statements
How to code if/else and switch statementsp. 248
How to code if/else statementsp. 248
How to code switch statementsp. 250
How to code loopsp. 252
How to code while and do-while loopsp. 252
How to code for loopsp. 254
How to code nested for loopsp. 256
How to code break and continue statementsp. 258
How to code break statementsp. 258
How to code continue statementsp. 260
Perspectivep. 262
Chapter 9 How to work with arrays, strings, and vectors
How to work with arraysp. 266
How to create an arrayp. 266
How to assign values to the elements of an arrayp. 268
Code examples that work with arraysp. 270
How to work with two-dimensional arraysp. 272
How to create a two-dimensional arrayp. 272
Code examples that work with two-dimensional arraysp. 274
More skills for working with arraysp. 276
The methods of the Arrays classp. 276
Code examples that work with the Arrays classp. 278
How to implement the Comparable interfacep. 280
How to reference an arrayp. 282
How to copy an arrayp. 282
How to work with the String classp. 284
Constructors of the String classp. 284
Code examples that create stringsp. 284
Methods of the String classp. 286
Code examples that work with stringsp. 288
How to work with the StringBuffer classp. 290
Constructors and methods of the StringBuffer classp. 290
Code examples that work with the StringBuffer classp. 292
How to work with the Vector classp. 294
Constructors and methods of the Vector classp. 294
Code examples that work with the Vector classp. 296
The Invoice applicationp. 298
The user interfacep. 298
The codep. 298
Perspectivep. 302
Chapter 10 How to handle exceptions and debug code
An introduction to exceptionsp. 306
The exception hierarchyp. 306
How exceptions are propagatedp. 308
Typical exceptions thrown by the Java APIp. 310
How to handle exceptionsp. 312
How to throw exceptionsp. 312
How to catch exceptionsp. 314
When and how to use conventional error trappingp. 316
How to throw and define your own exceptionsp. 318
How to throw your own exceptionsp. 318
How to define your own exceptionsp. 320
How to debug your classes without an IDEp. 322
How to use print statements to identify bugsp. 322
How to get information about an exceptionp. 324
How to print the stack trace to the consolep. 324
Perspectivep. 326
Section 3 Java for graphical user interfaces
Chapter 11 How to code a graphical user interface (part 1)
An introduction to the Swing classesp. 332
The user interface for the Loan Calculator applicationp. 332
The inheritance hierarchyp. 334
Methods of the Component classp. 336
How to work with framesp. 338
How to display a framep. 338
How to close a framep. 340
How to center a frame using the Toolkit classp. 342
How to work with panels, buttons, and eventsp. 344
How to add a panel to a framep. 344
How to add buttons to a panelp. 346
How to handle button eventsp. 348
An introduction to layout managersp. 350
How to use the Flow layout managerp. 350
How to use the Border layout managerp. 352
How to structure the layout codep. 354
How to work with labels and text fieldsp. 356
How to work with labelsp. 356
How to work with text fieldsp. 358
The Loan Calculator applicationp. 360
The user interfacep. 360
The codep. 360
Perspectivep. 366
Chapter 12 How to code a graphical user interface (part 2)
How to handle eventsp. 370
How event handling worksp. 370
A procedure for handling eventsp. 372
How to work with controlsp. 374
How to work with combo boxesp. 374
How to work with list boxesp. 378
How to work with scroll panesp. 382
How to work with bordersp. 384
How to work with text fields and text areasp. 386
How to work with radio buttonsp. 390
How to work with check boxesp. 394
A summary of other Swing componentsp. 396
How to work with layout managersp. 398
A summary of layout managersp. 398
How to work with the Grid Bag layout managerp. 400
How to set the constraints for a Grid Bag layoutp. 402
An example that uses the Grid Bag layout managerp. 404
How to code low-level eventsp. 406
A summary of low-level eventsp. 406
How to work with focus eventsp. 408
How to work with keyboard eventsp. 410
How to work with adapter classesp. 412
The Book Maintenance applicationp. 414
The user interfacep. 414
The Grid Bag layout and the codep. 416
Perspectivep. 426
Chapter 13 How to work with menus
Essential skills for working with menusp. 430
The hierarchy of classes for working with menusp. 430
How to add menusp. 432
How to add menu itemsp. 434
How to handle menu item eventsp. 436
How to create submenusp. 438
How to set keyboard mnemonicsp. 440
How to set accelerator keysp. 442
Advanced skills for working with menusp. 444
How to work with radio button menu itemsp. 444
How to work with check box menu itemsp. 446
How to work with pop-up menusp. 448
Perspectivep. 452
Chapter 14 How to work with fonts, colors, images, and shapes
How to work with fonts and colorsp. 456
How components are paintedp. 456
How to display text on a componentp. 458
How to set fontsp. 460
How to work with font metricsp. 462
How to set colorsp. 464
The Fonts and Colors applicationp. 466
The user interfacep. 466
The codep. 466
How to work with images and iconsp. 470
How to display imagesp. 470
How to display iconsp. 472
How to draw and fill shapes with the Graphics classp. 474
How to draw shapes with the Graphics classp. 474
How to fill shapes with the Graphics classp. 476
How to draw and fill shapes with the Java2D APIp. 478
An introduction to the Java2D APIp. 478
How to draw and fill shapes with the Java2D APIp. 480
The Shapes applicationp. 484
The user interfacep. 484
The codep. 484
Perspectivep. 486
Chapter 15 How to develop applets
An introduction to appletsp. 490
Two versions of the Loan Calculator appletp. 490
The inheritance chain for appletsp. 492
Applet deployment issuesp. 494
Applet security issuesp. 496
Four methods of an appletp. 498
How to develop Swing appletsp. 500
How to convert a Swing application to a Swing appletp. 500
How to code the HTML page for an appletp. 502
How to view an applet with the Applet Viewerp. 504
How to use the Java Plug-in HTML Converterp. 506
The code for the converted HTML pagep. 508
How to test a Swing appletp. 510
How to develop AWT appletsp. 512
How to convert a Swing application to an AWT appletp. 512
How to test an AWT appletp. 514
More skills for working with appletsp. 516
How to work with URLsp. 516
How to display images in appletsp. 518
How to work with JAR filesp. 520
How to include JAR files in an HTML pagep. 522
Perspectivep. 524
Section 4 Java for file input and output
Chapter 16 An introduction to file input and output
An introduction to file input and outputp. 530
How files and streams workp. 530
How to layer streamsp. 532
How to work with I/O exceptionsp. 534
How to work with the File classp. 536
How to create a File objectp. 536
Methods of the File classp. 538
Code examples that work with directories and filesp. 540
Perspectivep. 542
Chapter 17 How to work with text files
How to write text filesp. 546
Classes that write character output streamsp. 546
How to connect a character output stream to a filep. 548
How to write a text filep. 550
Three examples that write text filesp. 552
How to read text filesp. 554
Classes that read character input streamsp. 554
How to connect a character input stream to a filep. 556
How to read text filesp. 558
An example that reads numbers from a text filep. 560
How to read delimited text filesp. 562
Perspectivep. 564
Chapter 18 How to work with binary files
How to write binary filesp. 568
Classes that write binary output streamsp. 568
How to connect a binary output stream to a filep. 570
How to work with the DataOutput interfacep. 572
How to write a binary filep. 574
Examples that write binary filesp. 576
How to read binary filesp. 578
Classes that read binary input streamsp. 578
How to connect a binary input stream to a filep. 580
How to work with the DataInput interfacep. 582
How to read a binary filep. 584
Examples that read binary filesp. 586
How to combine two files into a single input streamp. 588
How to work with random-access filesp. 590
Constructors and methods of the RandomAccessFile classp. 590
How to read and write random-access filesp. 592
How to read and write fixed-length stringsp. 594
Examples that work with a random-access filep. 596
The I/O code for the Book Maintenance applicationp. 598
The user interface for this applicationp. 598
BookIO calls in the BookFrame and BookPanel classesp. 598
The code for the BookIO classp. 600
The code for the Book classp. 606
Perspectivep. 608
Section 5 Advanced Java skills
Chapter 19 How to use JDBC to work with databases
How a relational database is organizedp. 614
How a table is organizedp. 614
How the tables in a database are relatedp. 616
How the fields in a database are definedp. 618
How to use SQL to work with the data in a databasep. 620
How to query a single tablep. 620
How to join data from two or more tablesp. 622
How to modify data in a result setp. 624
How to access a database with Javap. 626
The four driver typesp. 626
How to configure an ODBC data sourcep. 628
How to connect to a databasep. 630
How to use Java to work with the data in a databasep. 632
How to return a result setp. 632
How to move the cursor through a result setp. 634
How to return data from a result setp. 636
How to modify data in a result setp. 638
How to work with prepared statementsp. 640
The Book Maintenance applicationp. 642
The user interface for this applicationp. 642
BookDB calls in the BookFrame and BookPanel classesp. 642
The code for the BookDB classp. 644
An introduction to working with meta datap. 648
How to work with meta datap. 648
How SQL data types map to Java data typesp. 650
Perspectivep. 652
Chapter 20 How to work with threads
An introduction to threadsp. 658
How threads workp. 658
Classes and interfaces for working with threadsp. 660
Constructors and methods for working with threadsp. 662
How to create and start threadsp. 664
How to extend the Thread classp. 664
How to implement the Runnable interfacep. 666
How to run an applet in its own threadp. 668
How to schedule threadsp. 670
How to put a thread to sleepp. 670
How to interrupt a threadp. 672
How to prioritize threadsp. 674
How to synchronize threadsp. 676
How to work with timersp. 680
How to use the utility timerp. 680
How to use the Swing timerp. 684
Perspectivep. 688