Posts

Showing posts from November, 2023

Lambda expression in Java. In English

Image
                                        LAMBDA EXPRESSION Lambda expressions are essentially ways for Java programmers to represent instances of functional interfaces (a functional interface is an interface that has just one abstract method). In Java, lambda expressions and lambda functions are synonymous. A lambda expression is a brief code block that takes in parameters and outputs a value. Java SE 8 has recently incorporated Lambda Expressions.  Functional interfaces are implemented by Lambda Expressions since they implement the single abstract function. Java 8 introduced lambda expressions, which offer the following features. Permit the handling of code as data or functionality as a method argument. A function that is not class-specific and can be built. Lambda expressions can be executed on demand and passed around just like any other object. Syntax: -       lambd...

Loops in Java. In English

Image
                                                                           LOOPS Programming languages provide a feature called looping that makes it easier to execute a collection of instructions or functions repeatedly while a condition is true. There are three ways to run the loops in Java. Although the core functionality offered by each method is comparable, there are differences in terms of syntax and condition checking time. While loop A control flow statement called a while loop enables code to be repeatedly run in response to a specified Boolean condition. You can think of the while loop as an iterative if statement.  syntax: - while (boolean condition) { loop statements... } Example: - import java.io.*; class Example {     public static void main (String[] args) {   ...

Conditions in java. In English

Image
              CONDITIONS AND STATEMENTS  Logical conditions Less than: a < b Less than or equal to: a <= b Greater than: a > b Greater than or equal to: a >= b Equal to:  a == b Not Equal to: a != b a OR b: a||b If statement The simplest expression for making decisions is the if clause in Java. It determines whether a given statement or block of statements will be performed or not; that is, whether a block of statements is executed if a given condition is met or not. Syntax: - if(condition) { // Statements to execute if // condition is true } Example: - public   class  Example {   public   static   void  main(String[] args) {        int  age= 25 ;        if (age>20 ){           System.out.print( "Age is greater than 20" );    ...