Learnitweb

Author: Editorial Team

  • Java 8 Stream – An Introduction

    Stream is basically a sequence of elements. The basic definition of stream is – A sequence of elements supporting sequential and parallel aggregate operations. Java 8 provided an additional package java.util.stream. It contains classes to support functional operations on streams of elements. We’ll discuss various operations on stream later. Let us see one example without…

  • Method references in Java

    Method references are a special type of lambda expressions. This feature was introduced in Java 8. Method references are often used to create simple lambda expressions by referencing existing methods. We use lambda expressions to create anonymous methods. Sometimes, a lambda expression does nothing but calls an existing method. In such cases, method references can…

  • Java program to print the sum of all elements of an array

    This is a programming question for beginners. The logic for this program is simple. Output

  • Primitive type functional interfaces

    Before we start, we should spend a minute to see what is autoboxing and unboxing. Autoboxing is the automatic conversion that the Java compiler does between the primitive types and their corresponding object wrapper classes. For example, converting an int to an Integer. Converting an object of a wrapper type to its corresponding primitive value…

  • Addition(+) and multiplication(*) operators with string in Python

    Python allows for the use of the addition (+) operator and multiplication (*) operator on strings. In this tutorial, we’ll see how to use these operators with string in Python. Addition(+) operator with string Adding two strings is known as concatenation. Concatenation of two strings creates a string by adding the second string to the…

  • Slicing String in Python

    Slicing is used to obtain a sub-string from a given string by slicing it from a given start and end. Here start and end mean the index within a given string. There is another optional parameter step which indicates the increment between each index for slicing. There are two ways to slice a Python string:…

  • BiConsumer interface in Java

    BiConsumer interface was introduced in Java 8. This interface is available in java.util.function package. BiConsumer represents an operation that accepts two arguments and return no result. BiConsumer is similar to the Consumer interface with the difference that BiFunction accepts two arguments whereas Consumer accepts only one. BiConsumer is expected to process the data and thus…

  • BiFunction interface in Java

    BiFunction interface was introduced in Java 8 and is available in java.util.function package. BiFunction represents a function that accepts two arguments and produces a result. BiFunction is similar to Function interface with the difference that BiFunction accepts two arguments whereas Function arguments accepts one argument. Methods in BiFunction interface default<V> BiFunction<T,U,V> andThen(Function<? super R,? extends…

  • BiPredicate interface in Java

    BiPredicate is a functional interface introduced in JDK 8. This interface is provided in java.util.function package. BiPredicate operates on two arguments and returns a boolean based on a condition. It is a functional interface and thus can be used in lambda expression also. BiPredicate is same as Predicate with the difference that it takes two…

  • Python program to convert time from 12 hour to 24 hour format

    Approach 1: Using slicing Whether the input time is in 12 hour format or not can be checked by checking the last two elements. If the last two elements are AM or PM then the input time is in 12 hour format.If PM, add 12 to the time. If AM, then don’t add. Output Approach…