Initial Values of Variables

Every variable in a program must have a value before its value is used:

  • Each array component is initialized with a default value when it is created. For type:

    • byte, the default value is zero, that is, the value of (byte)0.

    • short, the default value is zero, that is, the value of (short)0.

    • int, the default value is zero, that is, 0.

    • long, the default value is zero, that is, 0L.

    • BigInteger, the default value is zero, that is, 0IB.

    • float, the default value is positive zero, that is, 0.0f.

    • double, the default value is positive zero, that is, 0.0d.

    • BigDecimal, the default value is positive zero, that is, 0.0fb.

    • char, the default value is the null character, that is, '\u0000'.

    • Boolean, the default value is false.

    • String, the default value is the empty string, that is, "".

    • Prompt, the default value is the empty prompt, that is, P[].

    • Grammar, the default value is the empty grammar, that is, G[].

    • Document, the default value is the empty document, that is, DOC[].

    • Date, the default value is the current date at the time of interpretation.

    • Time, the default value is the current time at the time of interpretation.

    • Language, the default value is the system default language.

    • Currency, the default value is the system default currency.

    For all other reference types, the default value is null.

  • Each complex block expression argument is initialized to the corresponding argument value provided by the invoker of the expression.

  • An exception-handler parameter is initialized to the thrown object representing the exception and throw statements.

  • A local variable and the for statement must be explicitly given a value before they are used, by either initialization or assignment, in a way that can be verified by the parser using the rules for definite assignment.