Dart int operator-multiplication
Syntax & Examples


int.operator-multiplication operator

The `*` operator in Dart performs multiplication between two numbers.


Syntax of int.operator-multiplication

The syntax of int.operator-multiplication operator is:

operator *(num other) → num

This operator-multiplication operator of int multiplication operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredThe other number to multiply with.


✐ Examples

1 Multiplication

In this example,

  1. We create two integer variables num1 and num2 with values 5 and 3 respectively.
  2. We use the * operator to perform the multiplication operation between num1 and num2.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num1 = 5;
  int num2 = 3;
  int result1 = num1 * num2;
  print('Multiplication of $num1 and $num2: $result1');
}

Output

Multiplication of 5 and 3: 15

2 Multiplication

In this example,

  1. We create two integer variables num3 and num4 with values 10 and -2 respectively.
  2. We use the * operator to perform the multiplication operation between num3 and num4.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num3 = 10;
  int num4 = -2;
  int result2 = num3 * num4;
  print('Multiplication of $num3 and $num4: $result2');
}

Output

Multiplication of 10 and -2: -20

3 Multiplication

In this example,

  1. We create two integer variables num5 and num6 with values -4 and -3 respectively.
  2. We use the * operator to perform the multiplication operation between num5 and num6.
  3. We then print the result to standard output.

Dart Program

void main() {
  int num5 = -4;
  int num6 = -3;
  int result3 = num5 * num6;
  print('Multiplication of $num5 and $num6: $result3');
}

Output

Multiplication of -4 and -3: 12

Summary

In this Dart tutorial, we learned about operator-multiplication operator of int: the syntax and few working examples with output and detailed explanation for each example.