100% found this document useful (10 votes)
7K views830 pages

Murach's Java Programming

Belajar Javs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (10 votes)
7K views830 pages

Murach's Java Programming

Belajar Javs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 830

M urach

mu rach's

programming
4™ EDITION
JOEL MURACH

A CORE JAVA BOOK


that teaches you the Java essentials
at a professional pace,
using the time-saving features ofNetBeans

AN OBJECT-ORIENTED BOOK
that shows you how ro use business classes,
inheritance, and interfaces the way they’re
used in the real world

A GUI PROGRAMMING BOOK


that show's you how to develop graphical user
interfaces that handle events and validate data

A DATA ACCESS BOOK


that shows you how to develop
3-tier, object-oriented, database applications
the way the pros do it
TRAINING & REFERENCE

murach's

programming
4th EDITION
Joel Murach

M ike M u r a c h & A sso ciates , I n c .


4340 N. Knoll Ave. · Fresno, CA 93722
www.murach.com · [email protected]
Author: Joel Murach
Editor: Anne Boehm
Cover design: Zylka Design
Production: Maria Pedroza David

Books for Java programmers


Murach’s Java Programming
Murach’s Java Servlets and JSP

Books for database programmers


Murach’s Oracle SQL and PL/SQL
Murach’s MySQL
Murach’s SQL Server fo r Developers

Books for web developers


Murach ’s HTML5 and CSS3
Murach’s JavaScript and DOM Scripting
Murach’s PHP and MySQL

Books for .NET programmers


Murach’s C # 2010
Murach’s ASP.NET 4 Web Programming with C#2010
Murach’s ADO.NET 4 Database Programming with C# 2010
Murach’s Visual Basic 2010
Murach’s ASP.NET 4 Web Programming with VB 2010
Murach’s ADO.NET 4 Database Programming with VB 2010

Books for IBM mainframe programmers


Murach’s OS/390 and z/OS JCL
Murach’s Mainframe COBOL
Murach’s CICSforthe COBOL Programmer
DB2 for the COBOL Programmer, Part 1

© 2011, Mike Murach & Associates, Inc.


All rights reserved.

Printed in the United States of America

10 9 8 7 6 5 4 3 2 1
ISBN: 978-1-890774-65-3
Contents
Introduction XV

S ection 1 Essential Java skills


Chapter 1 How to get started with Java and NetBeans 3
Chapter 2 Introduction to Java programming 35
Chapter 3 How to work with data 79
Chapter 4 How to code control statements 111
Chapter 5 How to validate input data 145
Chapter 6 How to test and debug an application 167

S ection 2 O b ject-oriented program m ing w ith Java


Chapter 7 How to define and use classes 185
Chapter 8 How to work with inheritance 237
Chapter 9 How to work with interfaces 275
Chapter 10 Other object-oriented programming skills 311

S ection 3 M ore Jav a skills


Chapter 11 How to work with arrays 339
Chapter 12 How to work with collections and generics 363
Chapter 13 How to work with dates and strings 405
Chapter 14 How to handle exceptions 431

S ection 4 GUI program m ing w ith Swing


Chapter 15 How to develop a form 459
Chapter 16 How to work with controls and handle events 501
Chapter 17 How to develop and deploy applets 537

S ection 5 D ata access program m ing w ith Java


Chapter 18 How to work with text and binary files 559
Chapter 19 How to work with XML 613
Chapter 20 How to work with a Derby database 645
Chapter 21 How to use JDBC to work with a database 677

S ection 6 Advanced J ava skills


Chapter 22 How to work with threads 717
Chapter 23 How to deploy an application 751

A ppendixes
Appendix A How to set up your PC for this book 771
Appendix B How to set up your Mac for this book 111
E x p a n d e d c o n te n ts

Section 1 Essential Java skills


Chapter 1 How to get started with Java and NetBeans
Introduction to Java............................................................................. 4
Toolkits and platforms..................................................................................................... 4
How Java compares to C++ and C #................................................................................. 4
Applications, applets, and servlets.................................................................................. 6
The code for the console version of the Future Value application.................................. 8
How Java compiles and interprets code....................................................................... 10
Introduction to Java ID E s............................................................................................. 12
How to use NetBeans to work with existing projects................... 14
Introduction to Java projects and the NetBeans ID E ................................................... 14
How to open, close, and delete a project..................................................................... 16
How to compile and run a project................................................................................. 16
How to use the Output window with a console application........................................ 18
How to work with two or more projects........................................................................ 20
How to use NetBeans to develop new projects............................ 22
How to create a new project.......................................................................................... 22
How to set the Java version for a project....................................................................... 24
How to work with Java source code and files................................................................26
How to use the code completion feature........................................................................ 28
How to detect and correct syntax errors........................................................................ 30

Chapter 2 Introduction to Java programming


Basic coding skills............................................................................36
How to code statements................................................................................................. 36
How to code comments................................................................................................. 36
How to create identifiers.................................................................................................38
How to declare a class and a main method....................................................................40
How to work with numeric variables...............................................42
How to declare and initialize variables..........................................................................42
How to code assignment statements..............................................................................44
How to code arithmetic expressions..............................................................................44
How to work with string variables...................................................46
How to create a String object......................................................................................... 46
How to join and append strings..................................................................................... 46
How to include special characters in strings..................................................................48
How to use Java classes, objects, andmethods............................50
How to create objects and call methods........................................................................ 50
How to import Java classes............................................................................................ 52
How to use the API documentation to research Java classes........................................ 54
How to use the console for input and output................................ 56
How to use the System.out object to print output to the console................................. 56
How to use the Scanner class to read input from the console...................................... 58
Examples that get input from the console.....................................................................60
How to code simple control statements........................................ 62
How to compare numeric variables............................................................................... 62
How to compare string variables................................................................................... 62
How to code if/else statements...................................................................................... 64
How to code while statements....................................................................................... 66
Expanded contents V

Two illustrative applications............................................................. 68


The Invoice application.................................................................................................. 68
The Test Score application..............................................................................................70
How to test and debug an application............................................. 72
How to test an application..............................................................................................72
How to debug an application..........................................................................................72

Chapter 3 How to work with data


Basic skills for working with d a ta .................................................... 80
The eight primitive data types........................................................................................80
How to declare and initialize variables........................................................................ 82
How to declare and initialize constants....................................................................... 84
How to code assignment statements and arithmetic expressions.................................. 86
How to use the shortcut assignment operators...............................................................88
How to work with the order of precedence.................................................................... 90
How to work with casting...............................................................................................92
How to use Java classes for working with data typ es................... 94
How to use the NumberFormat class........................................................................... 94
How to use the Math class........................................................................................... 96
How to use the Integer and Double classes.................................................................98
The formatted Invoice application.................................................. 100
The code for the application....................................................................................... 100
A bug in the arithmetic............................................................................................... 102
How to debug the application..................................................................................... 102
How to use the BigDecimal class................................................... 104
The constructors and methods.................................................................................... 104
How to use BigDecimal arithmetic............................................................................. 106

Chapter 4 How to code control statements


How to code Boolean expressions................................................. 112
How to compare primitive data types......................................................................... 112
How to compare strings.............................................................................................. 114
How to use the logical operators................................................................................ 116
How to code if/else and switch statements................................... 118
How to code if/else statements................................................................................... 118
How to code switch statements................................................................................... 120
An enhanced version of the Invoice application......................................................... 124
How to code loops............................................................................126
How to code while and do-while loops...................................................................... 126
How to code for loops................................................................................................. 128
The Future Value application...................................................................................... 130
How to code nested loops........................................................................................... 132
How to code break and continue statements................................ 134
How to code break statements.................................................................................... 134
How to code continue statements.................................................................................136
How to code and call static methods............................................. 138
How to code static methods........................................................................................ 138
How to call static methods.......................................................................................... 138
The Future Value application with a static method..................................................... 140
Expanded contents

Chapter 5 How to validate input data


How to handle exceptions............................................................... 146
How exceptions w ork...................................................................................................146
How to catch exceptions............................................................................................. 148
The Future Value application with exception handling...............................................150
How to validate data......................................................................... 152
How to prevent exceptions from being thrown.......................................................... 152
How to validate a single entry................................................................................... 154
How to use generic methods to validate an entry...................................................... 156
The Future Value application with data validation........................158
The console................................................................................................................. 158
The co d e....................................................................................................................... 160

Chapter 6 How to test and debug an application


Basic skills for testing and debugging.......................................... 168
Typical test phases...................................................................................................... 168
The three types of errors............................................................................................. 168
Common Java errors.....................................................................................................170
A simple way to trace code execution....................................................................... 172
How to use NetBeans to debug an application.............................174
How to set and remove breakpoints........................................................................... 174
How to step through code........................................................................................... 176
How to inspect variables...............................................................................................176
How to inspect the stack trace.................................................................................... 178

Section 2 Object-oriented programming with Java

Chapter 7 How to define and use classes


An introduction to classes.............................................................. 186
How classes can be used to structure an application................................................. 186
How encapsulation works.............................................................................................188
The relationship between a class and its objects......................................................... 190
How to code a class that defines an object...................................192
How to use NetBeans to create a new class............................................................... 192
The code for the Product class.................................................................................... 194
How to code instance variables.................................................................................. 196
How to code constructors........................................................................................... 198
How to code m ethods.................................................................................................. 200
How to overload methods............................................................................................ 202
How to use the this keyword........................................................................................ 204
How to use NetBeans to work with classes.................................................................206
How to create and use an object....................................................208
How to create an object............................................................................................... 208
How to call the methods of an object.......................................................................... 210
How primitive types and reference types are passed to a method.............................. 212
A ProductDB class that creates a Product object........................................................214
A ProductApp class that uses a Product object...........................................................216
How to code and use static fields and methods...........................218
How to code static fields and methods........................................................................ 218
How to call static fields and methods.......................................................................... 220
How to code a static initialization block......................................................................222
When to use static fields and methods.........................................................................222
Expanded contents

The Line Item application................................................................ 224


The console...................................................................................................................224
The class diagrams....................................................................................................... 224
The code for the classes................................................................................................226

Chapter 8 How to work with inheritance


An introduction to inheritance........................................................ 238
How inheritance works.................................................................................................238
How the Java API uses inheritance.............................................................................. 240
How the Object class works......................................................................................... 242
How to use inheritance in your applications................................................................244
Basic skills for working with inheritance.......................................246
How to create a superclass........................................................................................... 246
How to create a subclass...............................................................................................248
How polymorphism works........................................................................................... 250
The Product application.................................................................. 252
The console...................................................................................................................252
The ProductApp class.................................................................................................. 254
The Product, Book, and Software classes.................................................................... 256
The ProductDB class....................................................................................................256
More skills for working with inheritance........................................260
How to get information about an object’s type............................................................260
How to cast objects...................................................................................................... 262
How to compare objects.............................................................................................. 264
How to work with the abstract and finalkeywords....................... 266
How to work with the abstract keyword...................................................................... 266
How to work with the final keyword......................................................................... 268

Chapter 9 How to work with interfaces


An introduction to interfaces.......................................................... 276
A simple interface.........................................................................................................276
Interfaces compared to abstract classes....................................................................... 278
Some interfaces of the Java A P I.................................................................................. 280
How to work with interfaces............................................................282
How to code an interface........................................................................................... 282
How to implement an interface.................................................................................... 284
How to inherit a class and implement an interface......................................................286
How to use an interface as a parameter..................................................................... 288
How to use inheritance with interfaces...................................................................... 290
How to use NetBeans to work with interfaces...........................................................292
A Product Maintenance application thatuses interfaces.............294
The class diagram.........................................................................................................294
The console...................................................................................................................296
The DAOFactory class..................................................................................................298
The ProductTextFile class............................................................................................ 298
The ProductMaintApp class........................................................................................ 300
How to implement the Cloneable interface...................................304
A Product class that implements the Cloneable interface...........................................304
A Lineltem class that implements the Cloneable interface........................................ 306
Viiî Expanded contents

Chapter 10 Other object-oriented programming skills


How to work with packages.............................................................312
An introduction to packages.........................................................................................312
How to use NetBeans to work with packages.............................................................. 314
How to use NetBeans to work with libraries................................................................316
How to use javadoc to document a package................................. 318
How to add javadoc comments to a class.....................................................................318
How to use HTML and javadoc tags in javadoc comments......................................... 320
How to use NetBeans to generate documentation....................................................... 322
How to view the documentation for a package............................................................ 322
How to code classes that are closely related................................ 324
How to code more than one class per file.....................................................................324
An introduction to nested classes.................................................................................326
How to work with enumerations..................................................... 328
How to declare an enumeration....................................................................................328
How to use an enumeration.......................................................................................... 328
How to enhance an enumeration...................................................................................330
How to work with static imports...................................................................................330

Section 3 More Java skills

Chapter 11 How to work with arrays


Basic skills for working with arrays............................................... 340
How to create an array.................................................................................................. 340
How to assign values to the elements of an array........................................................ 342
How to use for loops with arrays..................................................................................344
How to use enhanced for loops with arrays..................................................................346
More skills for working with arrays................................................ 348
The methods of the Arrays class................................................................................... 348
Code examples that work with the Arrays class.......................................................... 350
How to implement the Comparable interface.............................................................. 352
How to create a reference to an array...........................................................................354
How to copy an array.................................................................................................... 354
How to work with two-dimensional arrays.................................... 356
How to work with rectangular arrays...........................................................................356
How to work with jagged arrays................................................................................... 358

Chapter 12 How to work with collections and generics


An introduction to Java collections............................................... 364
A comparison of arrays and collections.......................................................................364
An overview of the Java collection framework............................................................366
An introduction to generics.......................................................................................... 368
How to use the ArrayList class....................................................... 370
The ArrayList class....................................................................................................... 370
Code examples that work with array lists.....................................................................372
An Invoice application that uses an array lis t............................... 374
An overview of the Invoice application........................................................................374
The code for the Invoice class......................................................................................376
The code for the InvoiceApp class...............................................................................378
Expanded contents ix

How to use the LinkedList class..................................................... 380


The LinkedList class..................................................................................................... 380
Code examples that work with linked lists...................................................................382
A class that uses a linked list to implement a generic queue....................................... 384
An enhanced version of the Invoice application........................... 386
An overview of the enhanced Invoice application....................................................... 386
The code for the InvoiceApp class...............................................................................388
How to work with m aps................................................................... 392
The HashMap and TreeMap classes.............................................................................392
Code examples that work with hash maps and tree m aps........................................... 394
How to work with legacy collections.............................................. 396
An introduction to legacy collection classes................................................................ 396
How to use an untyped collection.................................................................................398
How to use wrapper classes with untyped collections................................................. 400

Chapter 13 How to work with dates and strings


How to work with dates and tim es................................................. 406
How to use the GregorianCalendar class to set dates and times.................................. 406
How to use the Calendar and GregorianCalendar fields and methods........................408
How to use the Date class.............................................................................................410
How to use the DateFormat class to format dates and tim es....................................... 412
A DateUtils class that provides methods for handling dates....................................... 414
An Invoice class that includes an invoice date............................................................. 416
How to work with the String class.................................................. 418
Constructors of the String class....................................................................................418
Code examples that create strings.................................................................................418
Methods of the String class..........................................................................................420
Code examples that work with strings......................................................................... 422
How to work with the StringBuilder class..................................... 424
Constructors and methods of the StringBuilder class.................................................. 424
Code examples that work with the StringBuilder class............................................... 426

Chapter 14 How to handle exceptions


An introduction to exceptions........................................................ 432
The exception hierarchy...............................................................................................432
How exceptions are propagated....................................................................................434
How to work with exceptions.......................................................... 436
How to use the try statement........................................................................................ 436
How to use the try-with-resources statement............................................................... 438
How to use the methods of an exception..................................................................... 440
How to use a multi-catch block....................................................................................442
How to use the throws clause.......................................................................................444
How to use the throw statement....................................................................................446
How to work with custom exception classes................................ 448
How to create your own exception class.......................................................................448
How to use exception chaining.....................................................................................450
How to work with assertions........................................................... 452
How to code assert statements......................................................................................452
How to enable and disable assertions.......................................................................... 452
Expanded contents

Section 4 GUI programming with Swing


Chapter 15 How to develop a form
An introduction to S w ing.................................................................460
The user interface for the Future Value Calculator application................................... 460
The inheritance hierarchy for Swing components....................................................... 462
How to design a form........................................................................464
How to create a project for a GUI application...........................................................464
How to add a form to a project.................................................................................. 464
How to add controls to a form ................................................................................... 466
How to set properties.................................................................................................... 468
Common properties for forms and controls................................................................. 470
How to add code to a form .............................................................. 472
How to set the variable name for a control................................................................472
How to create an event handler for a control.............................................................474
How to rename or remove an event handler................................................................ 476
How to enter the code for a form..................................................................................478
Common methods for controls.....................................................................................480
How to display and center a form.................................................................................482
The code for the FutureValueFrame class................................................................... 484
How to validate Swing input data................................................... 486
How to display error messages.....................................................................................486
How to validate the data entered into a text field ........................................................ 488
The SwingValidator class............................................................................................. 490
How to validate multiple entries...................................................................................492
The Future Value application...........................................................494
The user interface......................................................................................................... 494
The co d e........................................................................................................................494

Chapter 16 How to work with controls and handle events


How to work with components........................................................502
How to work with text areas......................................................................................... 502
How to work with check boxes..................................................................................... 504
How to work with radio buttons...................................................................................506
How to work with combo boxes...................................................................................508
How to work with lists.................................................................................................. 510
The Payment application..................................................................514
The user interface......................................................................................................... 514
The co d e........................................................................................................................514
How to code low-level events..........................................................518
A summary of low-level events....................................................................................518
How to work with focus events....................................................................................520
How to work with keyboard events..............................................................................522
The Product Maintenance application........................................... 524
The user interface......................................................................................................... 524
The co d e........................................................................................................................526

Chapter 17 How to develop and deploy applets


An introduction to applets...............................................................538
The Future Value Calculator applet..............................................................................538
A brief history of applets.............................................................................................. 538
Applet security issues................................................................................................... 540
The inheritance hierarchy for applets...........................................................................542
Four methods of an applet............................................................................................ 542
Expanded contents XI

How to develop applets................................................................... 544


How to develop a panel for an applet.......................................................................... 544
How to code an applet..................................................................................................546
How to test an applet with the Applet Viewer............................................................. 546
How to deploy applets..................................................................... 548
A procedure for deploying an applet........................................................................... 548
How to create an HTML document for an applet........................................................ 550
How to run an applet within a web browser................................................................ 552

Section 5 Data access programming with Java


Chapter 18 How to work with text and binary files
Introduction to directories and files............................................... 560
A package for working with directories and files........................................................ 560
Code examples that work with directories and files....................................................562
Introduction to file input and output.............................................. 564
How files and streams work..........................................................................................564
A file I/O example........................................................................................................ 566
How to work with I/O exceptions.................................................................................568
How to work with text files .............................................................. 570
How to connect a character output stream to a file...................................................... 570
How to write to a text file .............................................................................................572
How to connect a character input stream to a file........................................................574
How to read from a text file..........................................................................................576
An interface for working with file I/O ......................................................................... 578
A class that works with a text file.................................................................................580
How to work with binary files.......................................................... 584
How to connect a binary output stream to a file.......................................................... 584
How to write to a binary file.........................................................................................586
How to connect a binary input stream to a file............................................................ 588
How to read from a binary file......................................................................................590
Two ways to work with binary strings......................................................................... 592
How to work with random-access files.......................................... 594
How to connect to a random-access file ...................................................................... 594
How to read to and write from a random-access file................................................... 596
How to read and write fixed-length strings.................................................................. 598
A class that works with a random-access file.............................................................. 600

Chapter 19 How to work with XML


Introduction to X M L ......................................................................... 614
An XML document.......................................................................................................614
XML tags, declarations, and comments...................................................................... 616
XML elements.............................................................................................................. 616
XML attributes.............................................................................................................. 618
An introduction to DTDs..............................................................................................620
How to view and edit an XML file.................................................... 622
How to view an XML file.............................................................................................622
How to edit an XML file...............................................................................................622
An introduction to three XML APIs................................................. 624
DOM ............................................................................................................................. 624
SA X .............................................................................................................................. 624
StAX............................................................................................................................. 624
xii Expanded, contents

How to use StAX to work with XML...............................................626


How to create an XMLStreamWriter object................................................................ 626
How to write X M L ....................................................................................................... 628
How to create an XMLStreamReader object............................................................... 630
How to read XML......................................................................................................... 632
A class that works with an XML file............................................................................636

Chapter 20 How to work with a Derby database


How a relational database is organized....................................... 646
How a table is organized............................................................................................... 646
How the tables in a database are related.......................................................................648
How the columns in a database are defined................................................................. 650
How to use SQL to work with the data in a database................. 652
How to query a single table..........................................................................................652
How to join data from two or more tables................................................................... 654
How to add, update, and delete data in a table............................................................ 656
An introduction to Derby................................................................658
An overview of D erby.................................................................................................. 658
How to configure your system to work with a Derby database...................................660
How to use the ij tool to work with a Derby database................ 662
How to start and stop the ij tool....................................................................................662
How to connect to and disconnect from a database..................................................... 662
How to create a database and connect to i t .................................................................. 664
How to run SQL statements....................................................................................... 664
How to run SQL scripts from the ij prompt...............................................................666
How to run SQL scripts from the command prompt.................................................668
How to start and stop the Derby database server...................... 670
How to start the server................................................................................................670
How to stop the server................................................................................................670
How to learn more about Derby.....................................................672
How to view the Derby documentation....................................................................... 672
How to navigate through the documentation............................................................... 672

Chapter 21 How to use JDBC to work with databases


An introduction to Java database drivers................................... 678
The four driver types..................................................................................................... 678
How to add a database driver to a project.................................................................... 680
How to use Java to connect to a database...................................682
How to load a database driver.......................................................................................682
How to connect to an embedded database................................................................... 684
How to disconnect from an embedded database.......................................................... 686
How to connect to a networked database..................................................................... 688
How to use Java to work with a database................................... 690
How to return a result set..............................................................................................690
How to move the cursor through a result s e t............................................................... 692
How to return data from a result s e t............................................................................ 694
How to modify data in a database.................................................................................696
How to work with prepared statements....................................................................... 698
Two classes for working with databases..................................... 700
A utility class for working with strings....................................................................... 700
A class that works with a database...............................................................................702
Expanded contents xiii

An introduction to working with metadata....................................708


How to work with metadata......................................................................................... 708
How SQL data types map to Java data types...............................................................710

Section 6 Advanced Java skills


Chapter 22 How to work with threads
An introduction to threads.............................................................. 718
How threads work.........................................................................................................718
Typical uses for threads............................................................................................... 718
Classes and interfaces for working with threads.........................................................720
The life cycle of a thread............................................................................................. 722
How to create threads...................................................................... 724
Constructors and methods of the Thread class............................................................724
How to create a thread by extending the Thread class................................................726
How to create a thread by implementing the Runnable interface............................... 728
How to manipulate threads............................................................. 730
How to set a thread’s priority....................................................................................... 730
How to interrupt a thread............................................................................................. 732
How to synchronize threads........................................................... 734
How to create synchronized threads............................................................................734
How to communicate among threads.......................................................................... 736
The Order Queue application..........................................................738
The operation................................................................................................................738
The classes....................................................................................................................740
The OrderQueueApp class........................................................................................... 742
The Order class.............................................................................................................742
The OrderTaker class................................................................................................... 744
The OrderHandler class............................................................................................... 746
The QrderQueue class................................................................................................. 746

Chapter 23 How to deploy an application


An introduction to deployment....................................................... 752
How executable JAR files work................................................................................... 752
How Java Web Start w orks.......................................................................................... 752
How an installer program works.................................................................................. 752
How to use an executable JAR file ................................................. 754
How to create an executable JAR file.......................................................................... 754
How to deploy a GUI application................................................................................ 756
How to deploy a console application........................................................................... 758
How to use Java Web Start.............................................................. 760
A procedure for using Java Web S tart......................................................................... 760
How to create a JNLP file............................................................................................ 762
How to create an HTML document that launches an application.............................. 764
How to deploy an application to a remote web server.................................................766
How to launch an application...................................................................................... 768
How to fix a common problem.................................................................................... 768
Introduction
Since its release in 1996, the Java language has established itself as one of
the leading languages for object-oriented programming. Today, Java continues
to be one of the most popular languages for application development, especially
for web applications and for mobile applications like Android apps. And that’s
going to continue for many years to come, for several reasons.
First, developers can obtain Java and a wide variety of tools for working
with Java for free. Second, Java code can run on any modem operating system.
Third, Java’s development has been guided largely by the Java community, and
Sun Microsystems released most of Java as open source software in 2007. As a
result, the Java platform is able to evolve according to the needs of the
programmers who use the language. Although Sun was acquired by Oracle
Corporation in 2010, Oracle has committed itself to supporting Java and the
Java community.

Who this book is for


This book is for anyone who wants to learn the core features of the Java
language. It works if you have no programming experience at all. It works if
you have programming experience with another language. It works if you
already know an older version of Java and you want to get up-to-speed with the
latest version. And it works if you’ve already read three or four other Java books
and still don’t know how to develop a real-world application.
If you’re completely new to programming, the prerequisites are minimal.
You just need to be familiar with the operation of the platform that you’re using.
If, for example, you’re developing programs using Windows on a PC, you
should know how to use Win