O'Reilly logo

Java All-in-One For Dummies, 4th Edition by Doug Lowe

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2

Working with Variables and Data Types

In This Chapter

arrow Creating proper variable declarations

arrow Discovering the difference between primitive and reference types

arrow Looking at Java's built-in data types

arrow Introducing strings

arrow Getting input from the console

arrow Getting input if you're using an older version of Java

In this chapter, you find out the basics of working with variables in Java. Variables are the key to making Java programs general purpose. The Hello, World! programs in the previous chapter, for example, are pretty specific: The only thing they say is “Hello, World!” But with a variable, you can make this type of program more general. You could vary the greeting so that sometimes it would say “Hello, World!” and at other times it would say “Greetings, Foolish Mortals.” Or you could personalize the greeting, so that it said “Hello, Bob!” or “Hello, Amanda!”

Variables are also ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required