Types of Operator

Arithmetic Operators
  • They are divided into two categories – Binary Arithmetic Operators and Unary Arithmetic Operators.
    • Binary Arithmetic Operators –
      • Binary operators are applied only on two operands.
      • Binary operators are – +, -, *, /, %
    • Unary Arithmetic Operators –
      • Unary operators are applied only on one operands.
      • Unary operators are – ++, – –
      • They are of two tyes – Increment unary operator and Decrement unary operator.
      • Increment Unary Operator is further divided into two parts – Pre Increment Unary Operator(++i) and Post Increment Unary Operator(i++).
      • Decrement unary operator is further divided into two parts – Pre decrement Unary Operator(–i) and Post Increment Unary Operator(i–).
Assignment Operators
  • Denoted by = symbol.
  • It is used to assign value to the variables. For example  int A = 12; int A = B; int C= A+B; char ch=’m’;
  • Assignment operator can be represented in the form of shorthand form, therefore, they are represented as – 
Relational Operators
Boolean Operators
Bitwise Operators
Class & Object Operators
Symbol Name Description
instance of Class Test Operator The first operand must be an object
reference. For example ‘A instance of B’, Returns true if A is an instance of B. Otherwise, it return false.
new Class Instantiation Creates a new object. For example: new A, in this A is either a call to a constructor, or an array specification.
“.” Class Member Access It accesses a method or field of a class or object. For example A.B used for ‘field access for object A’ and A.B() used for ‘method access for object A’
() Method Invocation For example: A(parameters) , Declares or calls the method named A with the specified parameters.
(type) Object Cast (type) A, in this example () operator Cost (convert) A to specific type. An exception will be thrown if the type of A is incompatible with specified type. In this type can be object or any primitive data type.
Others Operators
[ ] type [ ] Declares an array of unknown length, which contains type elements.
type[ A ]

Creates and array with A elements. Must be used with the new operator.
A[ B ] Accesses the element at index B within the array A. Indices begin at 0 and extend through the length of the array minus one.
+ A+B This binary operator concatenates one string to another. For example : –
String str1 = “Welcome”; String str2 = “Codershelpline”; String str3 = str1 + str2
Output str3 = Welcome Codershelpline.

                        

For Rest Operators Details Click This Link

 619 total views,  1 views today

Categories: Java

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.