Introduction - Java eLearning Kit For Dummies (2014)

Java eLearning Kit For Dummies (2014)

Introduction

If you’ve been thinking about taking a class online (it’s all the rage these days), but you’re concerned about getting lost in the electronic fray, worry no longer. Java eLearning Kit For Dummies is here to help you, providing you with an integrated learning experience that includes not only the book you hold in your hands but also an online version of the course at http://learn.dummies.com. Consider this introduction your primer.

About This Kit

Each piece of this eLearning Kit works in conjunction with the others, although you don’t need them all to gain valuable understanding of the key concepts covered here. Whether you follow along with the book, go online to see the course, or some combination of the two, Java eLearning Kit For Dummies teaches you how to:

· Install a copy of Java on your particular platform. (Windows, Linux, and Macintosh instructions are all provided.)

· Obtain an Integrated Development Environment (IDE) for your copy of Java, should you wish to use one.

· Write a basic Java program.

· Obtain help using Java to write applications for your machine.

· Use variables to store information for use in your application.

· Create and use objects that model real-world information.

· Employ the new date and time API for Java in your applications.

· Perform mathematical tasks using Java.

· Make decisions based on input that the application receives.

· Perform repetitive tasks.

· Decide what to do when an error occurs in your application.

· Use lambda expressions to make your code simpler and smaller.

· Work with collections of information.

· Make the output of your application look nice.

· Work with data that appears on your hard drive.

· Interact with the XML data that appears in so many different places (both on your local hard drive and online).

How This Book Is Organized

This book is split into the 13 chapters that are described in this section. You can find more information about using all the pieces of the multimedia kit together in the “Accessing the Java eCourse” section of this introduction.

Chapter 1: Starting with Java: Before you can begin doing anything with Java, you need a copy of Java on your system. More importantly, you need a copy of Java with all the current features. This chapter helps you obtain a current version of Java and install it on your Windows, Macintosh, or Linux system. You’ll also learn how to obtain an Integrated Development Environment (IDE, for short) should you wish to use one with the book. (You can use any text editor that you like.) Of course, when you have Java installed, you’ll want to create at least a basic program with it, so this chapter introduces you to Java programming techniques as well. Java is a rich language, so it’s important to know how to obtain help when you need it (even the professionals use help) — this chapter ends by showing you how.

Chapter 2: Using Primitive Variables: Variables provide a kind of storage box that you use to hold information while your application works with it. This chapter introduces you to basic variables that Java developers call primitives because they don’t require anything fancy to use them.

Chapter 3: Using Object Variables: Primitive variables have limitations. Yes, they’re simple to use, fast, and don’t require much memory, but they lack many of the features that developers want. This chapter introduces you to feature-rich object variables. The basic idea is the same as using primitive variables — variables are meant to hold data, after all — but object variables make it so much easier to perform special tasks that you’ll wonder how you got along without them. This chapter also introduces you to the new date and time API that makes working with both date and time significantly easier.

Chapter 4: Formatting Variable Content: The output from your application is important. Sure, you can output that number in any old way, but your user may not understand what it means. Formatting is an essential part of writing applications. To an extent, creating a nice output simply makes your application easier on the eyes, but formatting also contributes to understanding what the output means.

Chapter 5: Working with Operators: Many applications are used to perform math-related tasks. Operators provide a means of telling Java what math tasks to perform and the order in which you want them performed. There are also operators that help the application make decisions, such as whether one number is greater than another. In fact, you’ll use lots of operators in your application to tell Java how to view a particular variable, how to interact with it, or simply what task to perform with one or more variables.

Chapter 6: Working with Conditional Statements: Most applications have to make decisions based on the data they receive. For example, if a number is higher than the one you expected, then you need to tell the application what to do about it. Just as you make thousands of decisions every day, the applications you write must also make decisions to model the real world. This chapter helps you understand the methods that Java provides for making decisions.

Chapter 7: Repeating Tasks Using Loops: Writing an application that performs a task only one time doesn’t make too much sense. The time required to write the application is almost always greater than the time required for you to perform the task once. This chapter helps you create applications that can perform tasks more than once. Repetition is one of the fortes of computer systems. A computer will perform the same task as many times as you want precisely the same way every time.

Chapter 8: Handling Errors: Everyone makes mistakes. Even if a human isn’t involved, mistakes happen. A program can experience an error simply due to a hardware glitch or as the result of something that another application is doing on the host system. This chapter emphasizes the benefits of detecting errors and then doing something about them, rather than letting your application crash. If you’ve ever been upset because an application lost your data after a seemingly needless crash, then you’ll definitely want to read this chapter to avoid those problems in your own application.

Chapter 9: Creating and Using Classes: You’ll have seen objects used quite a bit by this point in the book. Java relies on classes to create objects. If you haven’t seen the class of your dreams, Java may not provide it. Never fear! You can create your own classes that meet any need that you can imagine. This chapter shows how to create classes that you can then use as objects in your applications to perform amazing tasks. It also demonstrates the use of lambda expressions, which is a new Java feature that will make your code smaller, faster, and less prone to errors.

Chapter 10: Accessing Data Sets Using Arrays and Collections: You see collections of things all around you. If you have a bookshelf, then you have a collection of books. When you go to the closet, you see a collection of clothing. A collection is an assortment of like items that are placed in a single storage container. This chapter helps you understand what collections (and the related arrays) are and how using them can make your application work better.

Chapter 11: Performing Advanced String Manipulation: The string is the most common variable used in Java because a string models how humans think about information. Every sentence you’ve read so far in this Introduction is a string. When you read any other book, you read strings. Look at an advertisement with writing and you see strings. In short, strings are everywhere. This chapter helps you perform some advanced tasks using strings that you’ll find helpful as your applications become more complex.

Chapter 12: Interacting with Files: Variables represent temporary storage of data in an application. When the application ends, the variables are destroyed and the data they contain is gone. Of course, you may want to store that information in some permanent form for later use. This chapter shows how to use files, which provide permanent storage for your data on the hard drive of your machine.

Chapter 13: Manipulating XML Data: Your machine contains a wealth of file types. Chapter 12 introduces you to text files, which provide a means of storing basic information as strings. Unfortunately, basic text files don’t have any intelligence — meaning they can’t communicate what the data they contain means. You can’t save the context of the information so that the information is easy to understand later. The eXtensible Markup Language (XML) makes it possible to add intelligence to data storage so that it’s possible to tell the difference between a name and a color later. This chapter provides a brief overview of working with XML in a Java application.

Conventions Used in This Book

A few style conventions will help you navigate the book part of this kit efficiently:

· Terms or words that I truly want to emphasize are defined in Lingo sections.

· Website addresses, or URLs, are shown like this: http://www.dummies.com.

· Numbered steps that you need to follow and characters you need to type (such as a user ID or password) are set in bold.

Foolish Assumptions

For starters, I assume you know what eLearning is, you need to find out how to build Java applications (and fast!), and you want to get a piece of this academic action the fun and easy way with Java eLearning Kit For Dummies.

I’m also assuming that you know the basics of working with your computer and the operating system installed on that computer. You need to know how to work with the input devices for your computer, perform basic tasks that require you to start applications, and how to perform tasks with those applications, such as using your browser to access information online. The first chapter provides instructions on how to install Java on your system, but it’s a plus if you’ve installed applications on your system before.

There are a number of places in the book where you’ll need to go online to perform tasks. For example, accessing basic Java help requires that you get online for the latest information. The Go Online icon (see the “Icons Used in This Kit” section) will also direct you to online resources that you’ll want to access.

Icons Used in This Kit

The familiar and helpful For Dummies icons point you in the direction of really great information that’s sure to help you as you work your way through assignments. Look for these icons throughout Java eLearning Kit For Dummies, in the book and in the electronic lessons.

tip.eps The Tip icon points out helpful information that’s likely to make your job easier.

remember.eps This icon marks an interesting and useful fact — something you probably want to remember for later use.

warning.eps The Warning icon highlights lurking danger. When you see this icon, pay attention and proceed with caution.

practice_fmt.eps Some programming concepts are a little harder to understand than others are. This icon points out ways in which you can improve your knowledge of these harder areas by practicing with the examples provided in that section of the chapter.

In addition to the icons, the book includes these friendly study aids that bring your attention to certain pieces of information:

· Lingo: When you see the Lingo box, look for a definition of a key term or concept.

· Go Online: Serving as your call to action, this box sends you online to view web resources, complete activities, or find examples.

· Extra Info: This box highlights something to pay close attention to in a figure or points out other useful information related to the discussion at hand.

Accessing the Java eCourse

Your purchase of this For Dummies eLearning Kit includes access to the course online at the For Dummies eLearning Center. If you have purchased an electronic version of this book, please visit http://www.dummies.com/go/getelearningcode to gain your access code to the online course. If you purchased the paperback book, you find your access code inside the front cover of this book.

Dummies eCourses require an HTML5-capable browser. If you use the Firefox or Chrome browser, make sure you have the latest version. Internet Explorer 10 is also HTML5-capable.

Class Is In

Now that you’re primed and ready, it’s time to begin. Most readers will want to start with Chapter 1. This chapter provides essential information for getting Java installed, obtaining and installing an IDE, creating a simple first application, and obtaining help about Java features. If you’re absolutely certain that you already know all of this information, then you can probably start with Chapter 2. If you feel like downloading the book’s sample Java code, head on over to http://www.dummies.com/go/javaelearning, where you’ll find the code nicely organized by chapter.