Java assignment operator example.

Java assignment operator example.

Posted in : Core Java Posted on : October 9, 2010 at 5:35 PM Comments : [ 0 ]

In this tutorial, you will see the use of assignment operater in java.

Java assignment operator example.

In this example, you will see the use of java assignment operator. The symbol of  assignment operator is "=". It is used for assigning the value to a variable. If the value already exists in that variable then it will be overwritten. you can also assign reference of other object.

The AssignmentOperator is a class in our program. It has a integer variable name "num". The obOperater is a object of AssignmentOperater class. It is used for accessing variable, and reassigning that variable.

package com.devmanuals;

public class AssignmentOperater {
	public static int num = 18;

	public static void main(String[] args) {
		AssignmentOperater obOperater = new AssignmentOperater();
		System.out.println("Value of variable.");
		System.out.println("Before assign value :"+obOperater.num);
		System.out.println("New value of variable after using assignment : ");
		System.out.println("New Value : "+obOperater.num);
Value of variable assign by assignment operator.

Download this code.

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics