Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Master-java Operators and Expressions

Related Tutorials


 
 

Share on Google+Share on Google+

Operators and Expressions

Advertisement
Operators are such symbols that perform some operations on one or more operands. Operators are used to manipulate primitive data types.

Operators and Expressions

     

Operators:

Operators are such symbols that perform some operations on one or more operands. Operators are used to manipulate primitive data types. Once we declare and initialize the variables, we can use operators to perform certain tasks like assigning a value, adding the numbers etc.
Java operators can be classified into different categories as shown:

  1. Simple Assignment Operators
  2. Arithmetic Operators
  3. Unary Operators
  4. Equality and Relational Operators
  5. Conditional (Logical) Operators
  6. Bitwise and Bit Shift Operators

   7.   Type Operators

Expressions:

In Java, an expression is like a statement without a terminator ( i.e. statement = expression + ; ). It is  made up of variables, operators, and method invocations, which are defined in accordance to the syntax of the language. The overall coding in a Java program is achieved through the expressions ( which may have single or multiple operations) . In all cases, a single evaluated value is obtained irrespective of composition of the multiple expressions. The evaluation  of an expressions is determined by the order of precedence of the operators.

Few of the examples of expressions are:

int number = 2

arr[0] = 10

int abc = a + (++b)* ((c / a)* b)

System.out.println("Hi,How are you")  // a compound expression

After executing an expression, a value is returned by an expression, it's data type depends on the elements used in the expression
Java also allows you to build the compound expression. 

There are three purposes for defining an expression :

  • To compute values.
  • To assign values to variables.
  • To control the flow of execution.
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2008

Related Tutorials

Discuss: Operators and Expressions   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
sanjay
October 21, 2011
Expressions

Pls tell me simplest ex: of expression.
vaishak olachery
October 4, 2012
Thanks

Dude thanks for this topic... This one helped me to write a project based on java thanks a lot :)
DMCA.com