O'Reilly logo

Java All-in-One For Dummies, 5th 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

check Creating proper variable declarations

check Discovering the difference between primitive and reference types

check Looking at Java’s built-in data types

check Introducing strings

check Getting input from the console

check 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 the ...

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