In Java, you can use the "times" operation (represented by the symbol "\*") to multiply two or more numbers together. Here are some examples:
Example 1: Multiplying two integers together
int x = 10;
int y = 5;
int result = x * y;
System.out.println(result); // Output: 50
In this example, the "times" operator is used to multiply the variables "x" and "y" together, resulting in the value of 50.
Example 2: Multiplying a double and an integer together
double x = 2.5;
int y = 3;
double result = x * y;
System.out.println(result); // Output: 7.5
In this example, the "times" operator is used to multiply the double "x" and the integer "y" together, resulting in the value of 7.5.
Example 3: Using the "times" operator in a for loop
for (int i = 1; i <= 10; i++) {
int result = i * 5;
System.out.println(result);
}
In this example, the "times" operator is used within a for loop to multiply the value of "i" (which increments from 1 to 10) by 5. The resulting value is printed to the console in each iteration of the loop.