INTRODUCTION

Image

Java is used on billions of devices worldwide. From mobile apps to desktop software, Java powers the largest enterprises and the smallest personal devices. Students, IT professionals, and anyone considering a career in programming will find that they need to learn Java. As a computer science professor who has taught Java for almost 20 years, I wrote this book to help you learn Java the way I learned to code: with hands-on projects. I’ve found that students learn best by building real apps and games that are interesting, engaging, and worth sharing. In this book, you’ll make a simple Hi-Lo guessing game, a Secret Messages app to exchange messages with friends, and an interactive drawing app called BubbleDraw. No prior programming experience is required, but if you have learned other languages, you’ll also pick up Java faster using this hands-on approach.

Why Should I Learn to Code?

First, jobs. According to the US Bureau of Labor Statistics, seven of the top ten fastest-growing, highest-paying job fields are in computing. Programmers are in demand worldwide, and millions more will be needed over the next several years. No matter where you are, as long as you have an internet connection, you can make money as a programmer.

But high income and job security aren’t the only reasons to learn to code. Coding is problem solving, and the world needs more problem solvers. You can write apps that connect people and help them work. You can enable new forms of commerce and even create entirely new markets. You can break down barriers, help an individual or a community or a whole continent, and create opportunities that hadn’t existed before. Thanks to the reach of the internet and smartphones, you can write an app and share it with billions of people.

Drew Houston, founder of Dropbox, says coding is “the closest thing we have to a superpower,” and Gabe Newell, cofounder of video gaming’s Valve Corporation, says knowing how to code makes you “look like you have magic powers compared to everybody else.” Computers are all around us—in every device, every system, and every network in our daily lives—and code is what makes all those computers work. Learn to code, and you learn to thrive in a high-tech future.

Why Should I Learn Java?

Java is considered by many to be the #1 programming language, for several good reasons. First, it runs on virtually every type of device imaginable, from desktops and laptops to smart TVs. The same Java code will run on Windows, macOS, or Linux.

Second, Java is used by companies to run some of the biggest enterprise applications. Java is an object-oriented programming language, designed to allow software engineers to develop massive applications in fields ranging from manufacturing to sales and human resources to accounting.

Third, Java is one of the most popular languages in colleges and universities worldwide, so it brings you up to speed with fellow coders right away.

Whether you’re coding as a hobby, as a side business, or as your full-time job, Java makes it free and easy to get started. Java is a great first language or a terrific next language if you’ve coded before.

What’s in This Book

Here’s a quick overview of what you’ll find in each chapter.

In Chapter 1, you’ll be guided through installing and setting up Java, Eclipse, and Android Studio. You’ll also write your first Java commands using the JShell interactive shell.

In Chapter 2, you’ll write your first application—the Hi-Lo guessing game, a text-based, command line program that has a player guess a random number between 1 and 100. In Chapter 3, you’ll upgrade the guessing game into a windowed, desktop application, complete with a graphical user interface (GUI) featuring labels, a text field, and a clickable button.

In Chapter 4, you’ll build your first Android mobile app, reusing much of the Hi-Lo guessing game code from the previous two chapters. Once you have the mobile app completed, in Chapter 5, you’ll add several finishing touches to the guessing game, including a settings menu and a high scores feature.

In Chapter 6, you’ll start a new program—the Secret Messages app, a text-based program that scrambles messages using a Caesar cipher. In Chapter 7, you’ll give the app a GUI upgrade by adding a slider bar tool that will allow you to crack Caesar ciphers quickly. Then, in Chapter 8, you’ll make a mobile Secret Messages app with sharing functionality, which will allow users to share secret messages back and forth by email, text message, or social media with the touch of a button.

In Chapter 9, you’ll begin creating the most visual application in the book—the BubbleDraw app, which allows the user to draw colorful bubbles on the screen. In Chapter 10, you’ll add animation to make the bubbles float and bounce around the screen as they’re drawn, and in Chapter 11 you’ll add multitouch functionality to draw bubbles in several places at once. By the end of this chapter, you’ll have a professional-looking app that you’ll want to share with all your friends!

Finally, in the appendix, you’ll find tips for debugging and avoiding common errors as you write Java programs in Eclipse and Android Studio.

What Tools Do I Need?

The programming tools you’ll learn to use in this book, Eclipse and Android Studio, are two of the most popular Java development tools used in industry, so once you finish this book, you’ll be ready to code real apps right away. Best of all, they’re free to download and use!

To get started, all you need is internet access and a regular desktop or laptop computer running Windows, macOS, or Linux. You don’t even need an Android phone or tablet to build mobile applications, because Android Studio comes with a free Android device emulator that you can use to test your apps. Of course, if you have an Android device, you’ll be able to run your mobile apps directly on your phone or tablet.

Online Resources

If you want extra help, you can download all the source code for the apps free on the book’s official website at https://www.nostarch.com/learnjava/. And, if you’d like step-by-step videos in a one-on-one tutorial style, the online course at http://www.udemy.com/java-the-easy-way/ will guide you through every example and every line of code. Use the coupon code BOOKHALFOFF to save 50 percent on the course. You can ask questions or message me directly in the online course anytime.

Start Now!

You’ve got nothing to lose and everything to gain by learning to code in Java. Start today. Coding is the key to a new world of possibilities, and learning Java could be your first step into a new career and a new future. Whether young or old, my university students have one thing in common: they took that first step. They wrote their first line of code and their first program, then learned and grew from there. You can do the same thing.

As the Chinese proverb says, “The best time to plant a tree was 20 years ago. The second best time is now.” Whether you’re still in school or considering embarking on a second career, the time to learn to code is now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.11