Our Ironclad Guarantee
You must be satisfied. Try our print books for 30 days or our eBooks for 14 days. If they aren't the best you've ever used, you can return the books or cancel the eBooks for a prompt refund. No questions asked!
This is the 6th Edition of our best-selling Java book. Since 2001, it has been used by thousands of beginning and experienced programmers to master the Java skills that are essential, whether you’re creating desktop, web, or mobile applications. Now revised to cover Java SE 17 and updated throughout, it focuses on today’s best practices, covers both NetBeans and Eclipse, and makes it easier than ever to learn Java, even if you’ve never programmed in any language before.
Go to our instructor’s site to learn more about this book and its instructor’s materials.
I love your Java book. It cuts right to the essential information, providing the perfect balance between too many details and too little information. I bought another well-known Java book, but I spent several hours trying to learn what I learned from your book in about 45 minutes."
You’ll be writing your first complete Java applications at the end of chapter 2!
By the end of chapter 9 (section 1), you’ll know how to use Java classes, objects, and methods to write applications that validate user input and use files to store your data.
Starting from chapter 1, you’ll take advantage of the time-saving features that an IDE provides as you use NetBeans or Eclipse to create, compile, run, test, and debug Java applications.
Chapter 7 introduces you to object-oriented programming (OOP), including the concept of encapsulation. Then, chapters 10 and 11 (section 2) explain inheritance and polymorphism in a way that cuts through the mystery and confusion these subjects can cause. At the end, you’ll know how to develop real-world, object-oriented, business applications.
Section 3 shows how to develop attractive graphical user interfaces (GUIs) with JavaFX, a modern library that’s designed to replace the aging Swing library.
In section 4, you’ll learn more Java skills that you’ll use all the time, like extra skills for working with strings, collections, lambdas, recursion, algorithms, dates, times, and databases. Each chapter in this section is independent of the others, so you can add these skills to your resume whenever you need them.
To complete your OOP training, chapter 19 shows you how to write database classes that map objects to a relational database. First, you’ll learn how to use SQL to work with a SQLite database. Then, you’ll learn how to use JDBC to work with any database.
All the content is in our distinctive paired-pages format, where each topic is presented in a two-page spread: the examples and reference material are on the righthand page with additional explanation on the left. This helps you learn faster by reading less...and it’s the ideal reference format when you need to refresh your memory about how to do something.
As for the examples, they include complete programs that build from the simple to the complex. We believe that studying the code for complete, real-world programs like these is critical. They tie all your newfound skills together to build your confidence and competence…unlike the trivial examples that you so often find in Java tutorials.
This book is for anyone who wants to learn the essentials of Java programming. It works:
This book is a favorite among developers who are moving into programming Android apps or Java web applications. Chapters 1-11 deliver the essential Java skills that you need, whether you’re looking for a first course in Java or a refresher.
This book has been updated from Java SE 9 to SE 17, which is the current long-term support (LTS) release. As part of this update, we have streamlined this book to do a better job than ever of setting the right pace for beginners.
New book features
New Java features
This book teaches you how to develop Java applications using:
Although this book covers Java SE 17, the code it presents will work with future versions of Java. In addition, this book clearly notes which features have been added since SE 9, which makes it possible to use this book with earlier releases too.
Beyond that, using the time-saving features of an IDE is not only the professional approach, it’s also the easiest and best way to learn Java. That’s why this book shows how to use NetBeans and Eclipse, the two most popular IDEs for Java development.
Appendix A (Windows) and Appendix B (macOS) in the book explain how to install the software, all of which is free.
“If you’re a Java virgin like I was before reading this book, then you’re going to love it. I had a development environment up & running within half an hour and was dabbling with code 15 minutes after that!”
- Andy Bonner, vbcity.com
"One of the things I really like is that this book uses an IDE to teach Java to the next generation of programmers. A lot of books on Java focus on the language itself [as though] an IDE plays no role in learning Java. Any professional programmer will tell you that an IDE is absolutely essential in making you more productive."
- John Yeary, Java Evangelist
“I love the 2-page style that you use in your Java book. It is such a great way to organize the lessons.”
- Dave Merton, Director of Development, Connecticut
"I bought this book to brush up on my Java programming skills in preparation for doing some Android programming. This book brought me up to speed really fast."
- Posted at an online bookseller
“This book really delivers for beginners in Java programming. It provides great exercises for you to use on your IDE and has them in an order that makes sense.”
- Posted at an online bookseller
"Ever have someone come in your office with a Java question, and you reach for a certain book that you know has the answer in it? Murach’s Java Programming is the resource that supplies these answers, both quickly and completely. If this book isn’t on your bookshelf, you should get it there."
- Robert Liguori, Tech Center Java User Group
“If I’d seen this book first, I would not have wasted money (and time) on 6 other books!”
- Posted at an online bookseller
"The information is so clear, it beats what I read in the Java tutorials on the Oracle web site. Once again, a Murach book adds clarity that’s hard to find elsewhere."
- Programmer, Denver, Colorado
“Terrific - Fantastic - Superlative! WELL worth several times the purchase price.”
- Posted at an online bookseller
View the table of contents for this book in a PDF: Table of Contents (PDF)
Click on any chapter title to display or hide its content.
Java timeline
Java editions
How Java compares to C++ and C#
Two types of desktop applications
Web applications and mobile apps
The code for a console application
How Java compiles and interprets code
How to use the command prompt to compile and run a Java application
An introduction to Java IDEs
An introduction to NetBeans
How to open and close a project
How to compile and run a project
How to work with the Output window
How to create a new project
An introduction to Eclipse
How to open and close a project
How to compile and run a project
How to work with the Console window
How to create a new project
How to declare a class and a main() method
How to code statements
How to code comments
How to declare and initialize variables
Rules and recommendations for naming variables
How to code arithmetic expressions
How to declare and initialize a string
How to join and append strings
How to include special characters in strings
How to import classes
How to create objects and call methods
How to print output to the console
How to read input from the console
How to compare numeric variables
How to compare string variables
How to code if/else statements
How to code while statements
The Invoice application
The Test Score application
How to test and debug an application
How to view the documentation for a class
The eight primitive data types
How to declare and initialize variables
How to declare and initialize constants
How to use the binary operators
How to use the compound assignment operators
How to use the unary operators
How to work with the order of precedence
How to work with casting
How to use the Math class
How to use the NumberFormat class
How to print formatted output to the console
The Invoice application with formatted output
How to debug a rounding error
How to use the relational operators
How to use the logical operators
How to code if/else statements
How to work with braces
How to code nested if/else statements
How to code switch statements
How to use arrow labels with switch statements
How to code switch expressions
The Invoice application with a switch expression
How to code while loops
How to code do-while loops
How to code for loops
The Future Value application
How to code nested loops
How to code break statements
How to code continue statements
The Guess the Number application
How to code static methods
How to call static methods
The Future Value application with a static method
The Guess the Number application with static methods
How exceptions work
How to catch exceptions
How to prevent exceptions
How to validate a single entry
How to code a method that validates an entry
The console
The code
Typical test phases
The three types of errors
Common Java errors
A simple way to trace code execution
How to set and remove breakpoints
How to step through code
How to inspect variables
How to inspect the stack trace
How to set and remove breakpoints
How to step through code
How to inspect variables
How to inspect the stack trace
How classes can be used to structure an application
How encapsulation works
The relationship between a class and its objects
The Product class
How to code instance variables
How to code constructors
How to code methods
How to create an object and call its methods
How to code static fields and methods
How to call static fields and methods
The ProductDB class
The console
The code
Reference types compared to primitive types
How to code a copy constructor
How to overload methods
How to use the this keyword
The console
The class diagram
The code
How to create an array
How to assign values to an array
How to use loops with arrays
How to work with rectangular arrays
How to fill, sort, and search arrays
How to refer to, copy, and compare arrays
The Number Cruncher application
A comparison of arrays and array lists
How to create an array list
How to add and get elements
How to replace, remove, and search for elements
How to store primitive values in an array list
The console
The Invoice class
The InvoiceApp class
How files and streams work
A file I/O example
How to use a try-with-resources statement to handle I/O exceptions
How to connect a character output stream to a file
How to write to a text file
How to connect a character input stream to a file
How to read from a text file
The ProductDB class
The console
The ProductManagerApp class
The exception hierarchy
How exceptions are propagated
How to declare a method that throws an exception
How to throw an exception
How to use the methods of an exception
How to code a finally block
How inheritance works
How the Object class works
How to create a superclass
How to create a subclass
How polymorphism works
The console
The Product class
The Book and Software classes
The ProductDB class
The ProductApp class
How to cast objects
How to check the type of an object
How to compare objects for equality
How to define a custom exception
How to work with abstract classes
How to work with the final classes, methods, and parameters
How to work with sealed classes
An introduction to records
How to use and customize records
When to use inheritance
When to use composition
A simple interface
Interfaces compared to abstract classes
How to code an interface
How to implement an interface
How to inherit a class and implement an interface
How to use an interface as a parameter
How to work with default and static methods
How to declare an enumeration
How to use an enumeration
How to enhance an enumeration
An introduction to packages
How to use NetBeans to work with packages
How to use Eclipse to work with packages
How to work with libraries
An introduction to the module system
How to create and use modules
How to add javadoc comments to a class
How to generate Java documentation
How to view the documentation
A GUI that displays ten controls
A summary of GUI frameworks
The inheritance hierarchy for JavaFX nodes
How to use NetBeans
How to use Eclipse
How to create and display a window
How to work with labels
How to set alignment and padding
How to work with text fields
How to set column widths
How to work with buttons and boxes
How to handle action events
The Future Value application
How to display an error message in a dialog box
How to validate the data entered into a text field
The Validation class
How to validate multiple entries
How to work with check boxes
How to work with radio buttons
How to work with combo boxes
How to work with date pickers
How to work with list views
How to work with text areas and scroll bars
The user interface
The code
How to compare strings
How to work with string indexes
How to modify strings
How to work with the characters in a string
The user interface
The CreateAccountApp class
How to work with text blocks
How to split and join strings
How to format strings
The user interface
The WordList class
The Hangman class
The HangmanApp class
An introduction to StringBuilder objects
How to use a StringBuilder object with a loop
The Java collection framework
More about generics
How to create a linked list and add and get elements
How to replace, remove, and search for elements
The Invoice application
How to sort a collection of numbers or strings
How to sort objects by implementing the Comparable interface
How to sort objects with a custom comparator
How to work with a stack
How to work with a queue
How to use generics to create a custom collection
The HashMap and TreeMap classes
Code examples that work with maps
The Word Counter application
Anonymous classes compared to lambdas
Pros and cons of lambda expressions
A method that doesn’t use lambdas
A method that uses lambdas
The syntax of a lambda expression
How to use the Predicate interface
How to use the Consumer interface
How to use the Function interface
How to work with multiple functional interfaces
How to filter a list
How to map a list
How to reduce a list
How to add a range of numbers
How to compute the factorial of a number
How to implement the binary search algorithm
How to calculate a value in the Fibonacci series
How to decide if you should use recursion
How to use the File class
The algorithm
A directory tree
The console
The code
The date/time API prior to Java 8
The date/time API for Java 8 and later
How to create date and time objects
How to get date and time parts
How to compare dates and times
How to adjust dates and times
How to add or subtract a period of time
How to get the time between two dates
How to format dates and times
An Invoice class that includes an invoice date
How a table is organized
How the columns in a table are defined
How tables are related
How to query a single table
How to join data from two or more tables
How to add, update, and delete data in a table
An introduction to SQLite
How to use DB Browser to view and edit a table in a SQLite database
How to use DB Browser to run SQL statements
How to create a SQLite database
Four types of JDBC database drivers
How to download a database driver
How to add a database driver to a project
How to connect to a database
How to return a result set and move the cursor through it
How to get data from a result set
How to work with prepared statements
How to insert, update, and delete data
The ProductDB class
Code that uses the ProductDB class
How to install the JDK
How to install the source code for this book
How to install Netbeans
How to install Eclipse
How to install DB Browser for SQLite
How to install the JDK
How to install the source code for this book
How to install Netbeans
How to install Eclipse
How to install DB Browser for SQLite
To give you an idea of how well this book works, you can download this chapter and try it out. It gets you started right by giving you some background on Java and showing you how to use an IDE to create, work with, compile, and run Java projects. By the end, you’ll be ready to start writing your own Java programs.
This download includes:
All the code is provided in both NetBeans and Eclipse formats.
All book files: Zip file Download Now
On this page, we’ll be posting answers to the questions that come up most often about this book. So if you have any questions that you haven’t found answered here at our site, please email us. Thanks!
There are no book corrections that we know of at this time. But if you find any, please email us, and we’ll post any corrections that affect the technical accuracy of the book here. Thank you!
For orders and customer service:
1-800-221-5528
Weekdays, 8 to 4 Pacific Time
If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.