Java Simple Assignment
In Java, Simple Assignment Operator is used to assign a value to a variable. In this tutorial, we will learn how to use Simple Assignment operator in Java, with examples.
The syntax to assign a value of 2
to variable x
using Simple Assignment Operator is
x = 2
Example
In the following example, we assign a value of 2
to x
using Simple Assignment Operator.
Main.java
public class Main { public static void main(String[] args) { int x; //simple assignment x = 2; System.out.println("x : " + x); } }
Output
x : 2
ADVERTISEMENT
Conclusion
In this Java Tutorial, we learned about Simple Assignment Operator in Java, with examples.