Skip to Main Content
Java For Dummies, 8th Edition
book

Java For Dummies, 8th Edition

by Barry Burd
April 2022
Beginner content levelBeginner
512 pages
11h 32m
English
For Dummies
Content preview from Java For Dummies, 8th Edition

Chapter 4

Making the Most of Variables and Their Values

IN THIS CHAPTER

Bullet Assigning values to things

Bullet Making things store certain types of values

Bullet Applying operators to get new values

The following conversation between Mr. Van Doren and Mr. Barasch never took place:

  • Charles: A sea squirt eats its brain, turning itself from an animal into a plant.
  • Jack: Is that your final answer, Charles?
  • Charles: Yes, it is.
  • Jack: How much money do you have in your account today, Charles?
  • Charles: I have fifty dollars and twenty-two cents in my checking account.
  • Jack: Well, you had better call the IRS, because your sea squirt answer is correct. You just won a million dollars to add to your checking account. What do you think of that, Charles?
  • Charles: I owe it all to honesty, diligence, and hard work, Jack.

Some aspects of this dialogue can be represented in Java by a few lines of code.

Varying a Variable

No matter how you acquire your million dollars, you can use a variable to tally your wealth. Listing 4-1 shows the code.

LISTING 4-1 Using a Variable

amountInAccount = 50.22;amountInAccount = amountInAccount + 1000000.00;

You don't have to type the code in Listing 4-1 (or in any of this book's ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Programming with Java For Dummies, 6th Edition

Beginning Programming with Java For Dummies, 6th Edition

Barry Burd
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 9781119861645Purchase Link