Any type of data at all:
- Primitive types, such as
- Object references.
We have not used arrays of object references so far in these notes.
They will be discussed in a future chapter.
Here is a short program:
Here is a description of the action:
// Review Program
void zero ( int x )
x = 0;
public static void main ( String args )
Alteration alt = new Alteration();
int value = 27;
System.out.println( "Before:" + value );
alt.zero( value );
System.out.println( "After:" + value );
- The program starts running with the static
Alteration object is constructed.
- The default constructor is used, since the class
does not define a constructor.
Alteration object contains the
- The primitive int variable
value is initialized to 27.
- The number currently held in
value is printed out.
zero() method is called with value as a parameter.
- Think about what happens next.
It is easy to make a mistake here.
- The number currently held in value is printed out.
What is printed out?