Decrement statement

It decrements the value of the instance.


Table of contents:


Format

Expression

--

Semicolon

Example

Format

The format is:


expression -- ;


This is a statement which an expression is followed by the postfix -- operator and a semicolon.

Decreases the value of the instance returned by the expression by 1.

Expression

An expression. Returned instance must be an int, long, or real class because it is decremented.

--

Postfix -- operator. Indicates that it is an decrement statement.

Semicolon

The end of a decrement statement is represented by a semicolon.

Example

1:

class example

2:

int var1;

3:

open method void someMethod()

4:

var1 = 10;

5:

var1--; // var1 is 9.

6:

em

7:

ec

Copyright © Rice All rights reserved.