Increment statement

It increments 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.

Increases 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 incremented.

++

Postfix ++ operator. Indicates that it is an increment statement.

Semicolon

The end of a increment 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 11.

6:

em

7:

ec

Copyright © Rice All rights reserved.