Java - Variables, Operators, and Keywords

<<Previous

Next >>




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

		instanceof      Compares 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 categories

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 and other datatypes (byte, short, int, long, float, double, boolean, char)

java keywords used for blocks

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

<<Previous

Next >>







Java - Variables, Operators, and Keywords

<<Previous

Next >>




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

		instanceof      Compares 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 categories

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 and other datatypes (byte, short, int, long, float, double, boolean, char)

java keywords used for blocks

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

<<Previous

Next >>







Learn about Stack Data Structure

Learn about Heap Data Structure

Learn about Operating System

Learn AVL Tree

Learn Djikstra's Algorithm