Learnitweb

Author: Editorial Team

  • Supplier interface in Java

    Supplier is a functional interface introduced in Java 8 and available in java.util.function package. This interface has functional method get(). Supplier does not take a argument and returns a result every time it is called. Here, T represents the type of the result. The supplier can be used in cases where there is no input…

  • Consumer interface in Java

    Consumer interface is predefined functional interface available in Java 8. This interface is available in java.util.function package. This interface represents an operation which accepts an input argument and does not return a result. Consumer interface has one functional method void accept(T t). There is another default method in Consumer interface: default Consumer andThen(Consumer after) void…

  • How to reverse a list in Python

    For the provided list, for example [1,2,3,4,5,6,7,8,9], task is to reverse the list. The output after reversing the list should be[9,8,7,6,5,4,3,2,1] We’ll discuss three ways to reverse the list: In-place reversal using reverse() method. Slicing the list using the [::-1] Creating a reversed iterator using reversed() built-in function. 1.Reverse a list using reverse() method Python…

  • Function interface in Java 8

    java.util.function.Function is part of java.util.function package. In Java 8, Function is a functional interface. It accepts one argument(object of type T) and produces a result (object of type R). Here, T is the Type of input to the function. R is the type of result of the function. In addition to abstract method apply(), this…

  • @Override annotation in Java

    @Override annotation was introduced in Java 1.5. @Override annotation indicates that the element is meant to override an element declared in super class. It is not required to use this annotation while overriding a method, but using @Override annotation helps in preventing errors. If you do not override a method marked with @Override correctly, the…

  • JSON Data Types

    JSON data types are: Null Number String Boolean Array Object Null Null is used to indicate that a data value does not exist, it is missing or that we do not know. A lack of value is not the same thing as a value of zero or empty string. Null is also not the same…

  • JSON syntax

    A very simple example of JSON is: Key-value pair or name-value pair syntax of JSON JSON starts with { (left brace). JSON ends with } (right brace). Keys in JSON are string in double quotes. Key and value in JSON is separated by : (colon). Each key-value pair in JSON is separated by , (comma).…

  • JSON – An Introduction

    JSON stands for (JavaScript Object Notation). The word JavaScript may mislead people that JavaScript is required to learn JSON. But this is not true. JavaScript here is in name because JSON is based on a subset of JavaScript. JSON is a lightweight data interchange format. Another commonly used data interchange format is XML. JSON is…

  • @Deprecated annotation in Java

    Over the time libraries, frameworks and APIs change. With every change comes the easy and simpler way of writing code. Whenever there is a change, we might not want people to use our old program elements like methods, constructors, fields and types. Such elements may be annotated as @Deprecated. @Deprecated annotation indicates that the marked…

  • Predefined annotation types in Java

    The predefined annotation types defined in java.lang are @Deprecated, @Override, @SuppressWarnings, @SafeVarargs and @FunctionalInterface. @Deprecated @Deprecated annotation indicates that the marked element is deprecated and should no longer be used. The compiler generates a warning whenever a program uses a method, class, or field with the @Deprecated annotation. When an element is deprecated, it should…