The assignment operator (=) in Java is used to assign a value to a variable. It takes the value on the right-hand side and assigns it to the variable on the left-hand side.
The assignment operator in Java is =
. Here's an example:
public class AssignmentExample {
public static void main(String[] args) {
// Assigning value to a variable
int number = 42;
// Displaying the value
System.out.println("The value of number is: " + number);
}
}
In this example, the value 42
is assigned to the variable number
using the assignment operator (=
). When you run this Java program, it will output "The value of number is: 42".