Saturday, March 12, 2005

Values

Introduction

Values is what programs work with. A value is data that is represented and stored in the computers memory. Examples of values are numbers and characters.

Program

This is how to write and represent the values 42, 'a' and true in source code:

class Main {
    public static void main(String[] args) {
        System.out.println(42);
        System.out.println('a');
        System.out.println(true);
    }
}

Note: The representation of the values in source code are called literals, and becomes values first when the program is compiled. Literals are used to hard-code data.

Output

42
a
true

No comments: