In this article Operators in Java we give the information about Operators and keywords play a very important role in Java. Such as Arithmetic Operators, Relational Operators, etc.
Operators in Java:
Operators and keywords play a very important role in Java.
-
Operators
Operators are symbols that are used to perform actions or calculations. These are used to change or compare the value of a variable.
Types of Major Operators:
- Arithmetic Operators: These operators are used for arithmetic calculations.
-
- + : Addition
- – : Subtraction
- * : Multiplication
- / : Division
- % : Modulus
- Relational Operators: These operators establish a relationship between two values.
-
- == : Equal to
- != : Not equal to
- > : Greater than
- < : Less than
- >= : Greater than or equal to
- <= : Less than or equal to
- Logical Operators: These operators are used for logical operations.
-
- && : Logical AND
- || : Logical OR
- ! :Logical NOT
- Assignment Operators: These operators are for assigning value to the variable.
-
- = : Assignment
- += : Add and assign
- -= : Subtract and assign
- *= : Multiply and assign
- /= : Divide and assign
- Increment and Decrement Operators: These operators are used to increase or decrease the value of the variable by 1.
-
- ++ :Increment
- — : Decrement
- Bitwise Operators: These operators are for performing operations at bit level.
-
- & : AND
- | : OR
- ^ : XOR
- ~ : NOT
- << : Left shift
- >> :Right shift
2.Keywords
Keywords in Java are special reserved words that are used to define a particular function or structure. We cannot use these as names of our own variables or methods.
Major keywords:
- Control Statements:
- if : If condition
- else : Else condition
- switch : Switch case
- case : Case
- for : For loop
- while : While loop
- do : Do-while loop
- break : Break loop
- continue : Continue loop
- Class Definition :
- class : Defines a class
- interface : Defines an interface
- extends : Inheritance
- implements : Implements interface
- Access Modifiers :
- public : Accessible to all
- private : Accessible within the class
- protected : Accessible within package and subclasses
- final : Cannot be changed
- Object Oriented Keywords:
- new : Creates a new object
- this : Refers to current object
- super : Refers to superclass
- static : Static method or variable
- abstract : Abstract class or method
- Exception Handling :
- try : Try block
- catch :Catch block
- finally : Finally block
- throw : Throw exception
- throws : Declare exception
- Miscellaneous :
- void : No return type
- return : Returns a value
- import : Imports a package
- package : Defines a package
- null :Null value
- true : True boolean value
- false : False boolean value
These were some of the major operators and keywords of Java, which are used in any Java programming language.
Some More:
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining