Learn Java the Easy Way
{3}————————————————
{4}————————————————
L e a r n J a v a the Easy Way
A Ha n d s – O n I n t r o d u c t i o n t o Programming
by Bryson Payne

San Francisco
{5}————————————————
Learn Java the Easy Way. Copyright 2018 by Bryson Payne.
| ISBN 1593278055 (pbk.)
| DDC 005.13/3–dc23
language)
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher.
ISBN-10: 1-59327-805-5
ISBN-13: 978-1-59327-805-2
Publisher: William Pollock
Production Editor: Riley Hoffman
Cover Illustration: Josh Ellingson
Interior Design: Octopod Studios
Developmental Editors: Jan Cash and Tyler Ortman
Technical Reviewer: Bryan Fagan
Copyeditor: Rachel Monaghan
Compositors: Riley Hoffman and Meg Sneeringer
Proofreader: Paula L. Fleming
Indexer: BIM Creatives, LLC.
For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly:
No Starch Press, Inc.
245 8th Street, San Francisco, CA 94103
phone: 1.415.863.9900; sales@nostarch.com
www.nostarch.com
Library of Congress Cataloging-in-Publication Data
Names: Payne, Bryson, author.
Title: Learn Java the easy way : a hands-on introduction to programming /
Bryson Payne.
Description: San Francisco : No Starch Press, Inc., [2018]
Identifiers: LCCN 2017022283 (print) | LCCN 2017035701 (ebook) | ISBN
9781593278465 (epub) | ISBN 1593278462 (epub) | ISBN 9781593278052 (pbk.)
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
Subjects: LCSH: Java (Computer program language) | Java (Computer program
LC record available at https://lccn.loc.gov/2017022283
Classification: LCC QA76.73.J38 (ebook) | LCC QA76.73.J38 P3955 2018 (print)
The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it.
{6}————————————————
About the Author
Dr. Bryson Payne is a tenured professor of computer science at the University of North Georgia, where he has taught aspiring coders since 1998. He is a Certified Information Systems Security Professional (CISSP) and Certified Ethical Hacker (CEH), among other industry certifications. He was also the first Department Head of Computer Science at UNG and the founding Director of the Center for Cyber Operations Education, an NSA Center of Academic Excellence in Cyber Defense. He enjoys working with K–12 schools worldwide to promote computer science education.
Featured in CIO magazine, Campus Technology, and the Wall Street Journal, Dr. Payne is also the best-selling author of Teach Your Kids to Code: A Parent-Friendly Guide to Python Programming (No Starch Press, 2015), now published in five languages (Korean, Portuguese, Russian, Chinese, and English). He’s also a popular online instructor of several courses, including the highly rated Udemy course Real-World Ethical Hacking (2017). His courses reach more than 20,000 enrolled students from more than 150 countries. He holds a PhD in computer science from Georgia State University and has published articles in scholarly and trade journals, in addition to speaking regularly at regional and national conferences on computer science and cybersecurity education.
Dr. Payne lives north of Atlanta, Georgia, with his lovely wife, Bev; two sons, Alex and Max; and three cats, Leo, Rocky, and Pixel.
About the Technical Reviewer
Bryan Fagan is a middle school engineering and technology teacher. He lives in Dahlonega, Georgia, where he teaches, enjoys the slow-rolling Appalachian mountains with his wife and daughter, and trains in Brazilian jiujitsu. He is the founder of Make Stuff, an after-school makerspace for middle school students.
{7}————————————————
{8}————————————————

{9}————————————————
{10}————————————————
B r i ef Contents
| Acknowledgments | xvii |
|---|---|
| Introduction | xix |
| Chapter 1: Getting Started | 1 |
| Chapter 2: Build a Hi-Lo Guessing Game App! | 19 |
| Chapter 3: Creating a GUI for Our Guessing Game | 43 |
| Chapter 4: Creating Your First Android App | 75 |
| Chapter 5: Polishing Your App by Adding Menus and Preferences | 109 |
| Chapter 6: Deciphering Secret Messages | 125 |
| Chapter 7: Creating Advanced GUIs and Sharing Your App | 147 |
| Chapter 8: Make Secret Messages a Phone App to Share with Friends! | 175 |
| Chapter 9: Paint Colorful Bubbles with Your Mouse! | 197 |
| Chapter 10: Adding Animation and Collision Detection with Timers | 221 |
| Chapter 11: Making BubbleDraw a Multitouch Android App | 249 |
| Appendix: Debugging and Avoiding Common Errors in Java | 273 |
| Index | 279 |
{11}————————————————
{12}————————————————