Book description
Cut through the noise and get real results with a step-by-step approach to learning Java programming
Key Features
- Ideal for the Java beginner who is getting started for the first time
- A step-by-step Java tutorial with exercises and activities that help build key skills
- Structured to let you progress at your own pace, on your own terms
- Use your physical copy to redeem free access to the online interactive edition
Book Description
You already know you want to learn Java, and a smarter way to learn Java 12 is to learn by doing. The Java Workshop focuses on building up your practical skills so that you can develop high-performance Java applications that work flawlessly within the JVM across web, mobile and desktop. You'll learn from real examples that lead to real results.
Throughout The Java Workshop, you'll take an engaging step-by-step approach to understanding Java. You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about Reactive programming and Unit testing. It's your choice. Learning on your terms, you'll build up and reinforce key skills in a way that feels rewarding.
Every physical copy of The Java Workshop unlocks access to the interactive edition. With videos detailing all exercises and activities, you'll always have a guided solution. You can also benchmark yourself against assessments, track progress, and receive free content updates. You'll even earn a secure credential that you can share and verify online upon completion. It's a premium learning experience that's included with your printed copy. To redeem, follow the instructions located at the start of your Java book.
Fast-paced and direct, The Java Workshop is the ideal companion for Java beginners. You'll build and iterate on your code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead.
What you will learn
- Get to grips with fundamental concepts and conventions of Java 12
- Write clean and well-commented code that's easy to maintain
- Debug and compile logical errors and handle exceptions in your programs
- Understand how to work with Java APIs and Java streams
- Learn how to use third-party libraries and software development kits (SDKs)
- Discover how you can work with information stored in databases
- Understand how you can keep data secure with cryptography and encryption
- Learn how to keep your development process bug-free with unit testing in Java
Who this book is for
Our goal at Packt is to help you be successful, in whatever it is you choose to do. The Java Workshop is an ideal Java tutorial for the Java beginner who is just getting started. Pick up a Workshop today, and let Packt help you develop skills that stick with you for life.
Table of contents
- Preface
-
1. Getting Started
- Introduction
-
Writing, Compiling, and Executing Your Hello World Program
- Exercise 1: Creating Your Hello World Program in Java
- Basic Syntax and Naming Conventions
- Printing Out Different Data Types
- Variables and Variable Types
- Exercise 2: Printing Different Types of Data
- Primitive versus Reference Data Types
- Null
- Chars and Strings
- Exercise 3: Declaring Strings
- Doing Some Math
- Exercise 4: Solving a Simple Trigonometry Problem
- Comments Help You to Share Code
- CLI versus GUI
- Exercise 5: Running the Code from the CLI
- Activity 1: Obtaining the Minimum of Two Numbers
- Summary
-
2. Learning the Basics
- Introduction
-
Controlling the Flow of Your Programs
- Exercise 1: Creating a Basic if Statement
- Comparison Operators
- Exercise 2: Using Java Comparison Operators
- Nested if Statements
- Exercise 3: Implementing a Nested if Statement
- Branching Two Ways with if and else
- Exercise 4: Using if and else Statements
- Using Complex Conditionals
- Exercise 5: Using Logical Operators to Create Complex Conditionals
- Using Arithmetic Operators in an if Condition
- The Ternary Operator
- Exercise 6: Using the Ternary Operator
- Equality Can Be Tricky
- Exercise 7: Comparing Decimal Values
- Comparing Strings
- Using switch Statements
- Exercise 8: Using switch
- Exercise 9: Allowing Cases to Fall Through
- Using Java 12 Enhanced switch Statements
- Exercise 10: Using Java 12 switch Statements
- Looping and Performing Repetitive Tasks
-
Handling Command-Line Arguments
- Exercise 15: Testing Command-Line Arguments
- Converting Command-Line Arguments
- Exercise 16: Converting String to Integers and Doubles
- Diving Deeper into Variables — Immutability
- Comparing Final and Immutable
- Using Static Values
- Using Local Variable Type Inference
- Activity 1: Taking Input and Comparing Ranges
- Summary
- 3. Object-Oriented Programming
- 4. Collections, Lists and Java's Built-In APIs
- 5. Exceptions
-
6. Libraries, Packages, and Modules
- Introduction
-
Organizing Code into Packages
- Importing Classes
- Exercise 1: Importing Classes
- Fully Qualified Class Names
- Importing All Classes in a Package
- Dealing with Duplicated Names
- Static Imports
- Creating a Package
- Naming Your Package
- Directories and Packages
- Exercise 2: Creating a Package for a Fitness Tracking App
- Building JAR Files
- Exercise 3: Building a JAR File
- Defining the Manifest
- Exercise 4: Building an Executable JAR File
- Build Tools
- Maven
- Exercise 5: Creating a Maven Project
- Exercise 6: Adding Java Sources to the Maven Project
- Exercise 7: Building the Maven Project
- Exercise 8: Creating an Executable JAR with Maven
- Using Gradle
- Exercise 9: Creating a Gradle Project
- Exercise 10: Building an Executable JAR with Gradle
- Using Third-Party Libraries
- Finding the Libraries
- Adding a Project Dependency
- Exercise 11: Adding a Third-Party Library Dependency
- Using the Apache Commons Lang Library
- Exercise 12: Using the Apache Commons Lang Library
- Using Modules
- Creating Modules
- Exercise 13: Creating a Project for a Module
- Exercise 14: Creating a Second Module Using the First One
- Activity 1: Tracking Summer High Temperatures
- Summary
-
7. Databases and JDBC
- Introduction
- Relational Databases
- Relational Database Management Systems
-
Introducing SQL
- Exercise 2: Creating the customer Table
- Inserting Data into a Table
- Exercise 3: Inserting Data
- Retrieving Data
- Relating Tables
- Exercise 4: Creating the email Table
- Selecting Data from Multiple Tables
- Modifying Existing Rows
- Exercise 5: Modifying email Data
- Deleting Data
- JDBC—Accessing Databases from Java
- Connecting to Databases
- Querying Data with JDBC
- Exercise 6: Querying Data with JDBC
- Sanitizing User Input
- Using Prepared Statements
- Transactions and Rollback
- Exercise 7: Using Prepared Statements with Transactions
- Simplifying JDBC Programming
- Using Object-Relational Mapping Software
- Database Connection Pooling
- Non-Relational, or NoSQL, Databases
- Activity 1: Track Your Progress
- Summary
- 8. Sockets, Files, and Streams
- 9. Working with HTTP
- 10. Encryption
- 11. Processes
- 12. Regular Expressions
- 13. Functional Programming with Lambda Expressions
- 14. Recursion
- 15. Processing Data with Streams
- 16. Predicates and Other Functional Interfaces
- 17. Reactive Programming with Java Flow
-
18. Unit Testing
- Introduction
-
Getting Started with Unit Tests
- Introducing JUnit
- Writing Unit Tests with JUnit
- Exercise 1: Writing a First Unit Test
- Exercise 2: Writing a Successful Test
- Deciding What to Test
- Writing Parameterized Tests
- Exercise 3: Writing a Parameterized Test
- When Tests Won't Work—Disabling Tests
- Test Setup
- Exercise 4: Using Test Setup and Cleanup Methods
- Mocking
- Testing with Mocks Using Mockito
- Exercise 5: Using Mocks when Testing
- Activity 1: Counting the Words in the String
- Summary
-
Appendix
- 1. Getting Started
- 2. Learning the Basics
- 3. Object-Oriented Programming
- 4. Collections, List, and Java's Built-In APIs
- 5. Exceptions
- 6. Libraries, Packages, and Modules
- 7. Databases and JDBC
- 8. Sockets, Files, and Streams
- 9. Working with HTTP
- 11. Processes
- 12. Regular Expressions
- 13. Functional Programming with Lambda Expressions
- 14. Recursion
- 15. Processing Data with Streams
- 16. Predicates and Other Functional Interfaces
- 17. Reactive Programming with Java Flow
- 18. Unit Testing
- What Next?
Product information
- Title: The Java Workshop
- Author(s):
- Release date: October 2019
- Publisher(s): Packt Publishing
- ISBN: 9781838986698
You might also like
book
Java By Comparison
Write code that's clean, concise, and to the point: code that others will read with pleasure …
book
The Well-Grounded Java Developer, Second Edition
Understanding Java from the JVM up gives you a solid foundation to grow your expertise and …
book
Java Projects - Second Edition
Learn how to build scalable, resilient, and effective applications in Java that suit your software requirements. …
video
Modern Java Collections
More than 6 hours of video training covering Java Collections, including design considerations and features added …