Krivalar Tutorials 
Krivalar Tutorials

Java - Variables, Operators, and Keywords


<Package

Data Types >





Java variables

Java variables are represented using variable names. Variable names can contain characters, numbers

Java operators

Arithmetic Operators

+Addition operator when used on Numbers
Concatenation when used with Strings and char
-Subtraction operator
*Multiplication operator
/Division operator
%Remainder operator

Relational Operators

>Greater than
>=Greater than or equal to
<Less than
<=Less than or equal to
==Equal to
!=Not equal to

Conditional Operators

&&Conditional AND operator
||Conditional OR operator
?:Ternary operator (alternate to if-else statement)

Unary Operators

+Unary plus operator.
-Unary minus operator. Used to make a number or expression negative
++Increment operator. Increments a value by 1
--Decrement operator. Decrements a value by 1
!Logical Not operator. Used on boolean values

Assignment Operator

=assignment operator. used to assign values to variables

Type Comparison Operator

instanceofCompares an object to a specified type

Bit Operators

~Unary bitwise complement
<<Signed left shift
>>Signed right shift
>>>Unsigned right shift
&Bitwise AND operator
^Bitwise exclusive OR
|Bitwise inclusive OR

Java access modifiers

  • private
  • protected
  • public
  • default

Java Keywords

java keywords used with class methods

static, final, abstract, synchronized, throws

java keywords used with class definition

class, static, final, abstract, implements, extends

java keywords used on interfaces or in interface definition

interface, extends

All interfaces are inherently static, final and abstract and hence cannot be otherwise and there is no need to specify explicitly

java keywords used on variables

static, final, volatile,
byte, short, int, long, float, double, boolean, char

java keywords used for blocks

if, else, for, while, do, switch, case, default, try, catch, finally

<Package

Data Types >





















Searching using Binary Search Tree