
The Java Workshop
A Practical, No-Nonsense Introduction to Java Development
- 604 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
The Java Workshop
A Practical, No-Nonsense Introduction to Java Development
About this book
Get to grips with the fundamentals of Java programming and learn to build useful applications with the help of real-world examples and engaging practical activities
Key Features
- Build a solid foundation in Java and focus on developing real-world applications
- Implement the fundamental concepts of object-oriented programming in your code
- Work with external data storage systems and learn how to efficiently handle data
Book Description
Java is a versatile, popular programming language used across a wide range of industries. Learning how to write effective Java code can take your career to the next level, and The Java Workshop will help you do just that. This book is designed to take the pain out of Java coding and teach you everything you need to know to be productive in building real-world software.
The Workshop starts by showing you how to use classes, methods, and the built-in Collections API to manipulate data structures effortlessly. You'll dive right into learning about object-oriented programming by creating classes and interfaces and making use of inheritance and polymorphism. After learning how to handle exceptions, you'll study the modules, packages, and libraries that help you organize your code. As you progress, you'll discover how to connect to external databases and web servers, work with regular expressions, and write unit tests to validate your code. You'll also be introduced to functional programming and see how to implement it using lambda functions.
By the end of this Workshop, you'll be well-versed with key Java concepts and have the knowledge and confidence to tackle your own ambitious projects with Java.
What you will learn
- Write clean, well-commented Java code that's easy to maintain
- Debug logical errors and handle exceptions in your Java programs
- Implement object-oriented and functional programming paradigms
- Use regular expressions to search for information in text data
- Work with information stored in databases using JDBC
- Make HTTP requests from Java applications and parse the response data
- Secure your data with cryptography and encryption
- Write unit tests to validate your code with JUnit
Who this book is for
This Java coding book is designed for anyone who is new to Java. Whether you're an aspiring software developer, or are just curious about learning to code, then this book will get you on the right track. No prior programming experience is required.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
1. Getting Started
Introduction
Writing, Compiling, and Executing Your Hello World Program
- static signifies that there is nothing in the system instantiating the main method. Because of the way the Java Virtual Machine works, the main method needs to be static, or it will not be possible to execute it.
- void indicates that the main method will not be returning anything to any code calling it. Methods could, in fact, send an answer to a piece of code executing it, as we will see later in the book.
- main is the name of the method. You cannot assign this a different name, since it is the method that makes the program executable and needs to be named this way.
- String[] args are the parameters of the main method. Parameters are passed as a list of strings. In other words, the program could take arguments from other parts within your computer and use them as data. In the particular case of the main method, these are strings that could be entered on the command-line interface (CLI) when calling the program.
Exercise 1: Creating Your Hello World Program in Java
- Open IntelliJ and you will see a window giving you several options. Click on Create New Project. It should be the first option in the list:
Figure 1.1: Creating a new project on IntelliJ IDE - A new interface should appear. The default options here are meant for creating a Java program, so you just need to click Next:
Figure 1.2: Creating a new Java project - Check the box to create the project from a template. Click on Java Hello World and then click Next:
Figure 1.3: Create a Java Hello World project from template - Name the project chapter01. Then, click Finish:
Figure 1.4: Create a Hello World Project - As we haven't chosen a folder to store the projects (intentionally), IntelliJ will offer you the possibility to create a default project folder inside your user space. Click OK:
Figure 1.5: Default project folder option on IntelliJ IDE - You will see a popup with tips on how to use the software. If you have never used a development environment of this type before, then this is a good way to get information about how it functions every time IntelliJ boots up. Choose your preferences and then click Close:
Figure 1.6: Tip on how to use the IDE - IntelliJ reminds you regarding the possibility of using a special tab dedicated to learning more about the environment in relation to programming. Click Got It.
- The editor presents a menu bar, a code navigation bar, a project navigation area, and the actual editor where you can see the code we explained earlier. Now it is time to test it. Click on the Run button (this is the triangle on the right-hand side of the code navigation bar).
Figure 1.7: Execute the program by clicking on the Run button - When the program runs, a terminal window unfolds at the bottom of IntelliJ. Here, you can see how the software called your JVM, the program's outcome, and a line from the ...
Table of contents
- Preface
- 1. Getting Started
- 2. Learning the Basics
- 3. Object-Oriented Programming
- 4. Collections, Lists 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
- 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
- Appendix