Introduction to Lambda Expressions

Simply speaking, Lambda Expressions are basically anonnymous functions.

Lambda Expressions, in the past decade, have been introduced almost all major progamming languages due to their simplicity and conciseness. In java lambda expressions were introduced in Jav...

Suspending a Thread through sleep()

Threads can be suspended using the static sleep() method.

The sleep() method is defined in the Thread class and has two overloads:

public static void sleep(long millis)
public static void sleep(long millis, int nanos)

The sleep() will suspend the t...

A conditional expression evaluates an expression based on a given condition.

They are used normally to assign a value to a variable that is restricted by a certain condition.

For example if age is greater than 17, then adult otherwise child.

if(age > 17)
{
    person="Adult";
}else{
    perso...

The logical operators are normally used to create a compound boolean expression.

In java they inlcude:

  1. ! - 'logical not operator'
  2. && - 'logical and operator'
  3. || - 'logical or operator'
  4. ^ - 'exclusive logical or operator'

Logical operators are important when you want to execute a stat...

Threads - Flow of Execution

A thread is a flow of execution in a process.

Any program atleast has one thread of execution in its process. As per our needs, we are free to create additional flows of execution.

This allows us perform tasks concurrently. Concurrent applications are applications t...

Java Threads - Two ways of Thread Creation

A Thread, we said, is a separate execution paths within a process.

Threads in Java can be created in two ways:

  1. By extending the java.lang,Thread class.
  2. By implementing the Runnable interface.

1. Extending Thread

A thread can be created b...

A thread is a path of execution that exists within a process.

One process may have one or more threads.

A Single-threaded process has one thread while a multi-threaded process has more than one threads.

In the single-threaded process, we have only one flow of execution of instructions whi...

A switch statement executes statements based on the value of a variable or an expression.

Switch statements simply working with several conditions. Normally an if statement makes selctions based on a single true or false condition.

Switch statements have the following syntax:

        swi...

Methods in Java

A method is used to encpsulate a unit of reusable code.

Methods organize and simplify coding.

Method definition

A method definition comprises the following:

  1. Method name.
  2. Method Parameters.
  3. Return type.
  4. Method body
modifier returnType methodName(parameters) {
    //...

Java Array Class

In the java.util package is defined an Arrays class that has useful methods for common operations like sorting and searching.

These methods are static and hence don't need an Arrays instance for their invokation.

Some of the common operations that can be performed inclu...