The compound assignment operator (*=) in Java is used to multiply the right operand by the left operand and assign the result to the left operand. In this case, y *= 3 is equivalent to y = y * 3.
public class CompoundAssignmentExample {
public static void main(String[] args) {
// Define the initial value of y
int y = 5;
// Use the compound assignment with multiplication (y *= 3)
y *= 3;
// Display the result
System.out.println("Value of y after y *= 3: " + y);
}
}
When you run this program, it will output:
Value of y after y *= 3: 15