Java

  1. Home
  2. Computing & Technology
  3. Java
photo of Paul Leahy

Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Java Term of the Week: Variable

Saturday November 29, 2008

Seeing as I had a look at declaring variables this week, it seems a good idea to re-enforce what they are. A variable is a container that holds values that are used in a Java program. When I first started programming I always thought of them as a bucket to put something in. For example, if I wanted to hold the approximate population of the Earth I could create a variable:

long populationOfEarth = 6700000000L;

The variable "populationOfEarth" is declared to be a long data type and initialized to a value of 6.7 billion. Note the use of the "L" at the end of the statement. A whole number literal is treated as an int value unless you specifically tell the compiler that it's a long.

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Java

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Java

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.