#72 Functional Interface New in Java

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024
  • Check out our courses:
    Enterprise Java Spring Microservices: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : go.telusko.com...
    Coupon: TELUSKO20 (20% Discount)
    For More Queries WhatsApp or Call on : +919008963671
    Udemy Courses:
    Spring: go.telusko.com...
    Java:- go.telusko.com...
    Java Spring:- go.telusko.com...
    Java For Programmers:- go.telusko.com...
    Python : go.telusko.com...
    Git : go.telusko.com...
    Docker : go.telusko.com...
    website : courses.telusk...
    In this lecture, we are discussing functional interface:
    #1 what is functional Interface?
    --functional interface is an interface with only one abstract method
    #2
    The properties of a functional interface in Java are as follows:
    Single Abstract Method: A functional interface has only one abstract method.
    This method is the signature of the interface and defines the behaviour that will be implemented in the lambda expression or with simple class.
    Functional Method: The abstract method of a functional interface is called the functional method.
    It is the method that provides the functional behaviour of the interface.
    @FunctionalInterface Annotation: A functional interface is annotated with the @FunctionalInterface annotation.
    This annotation is optional, but it provides a compile-time check that the interface has only one abstract method.
    Compatible with Lambda Expressions: A functional interface is compatible with lambda expressions.
    A lambda expression is a concise way of implementing the functional method of a functional interface.
    (This will discuss in next lecture of lambda expression).
    Functional interfaces are a key component of functional programming in Java,
    and they are used extensively in the Java 8 Streams API and other Java libraries.
    #3 Example
    class Main{
    public static void main(String []args){
    A obj = new B();
    obj.show();
    //another way to implement functional interface
    A obj1 = new A(){
    @Override
    public void show(){
    System.out.println("Hello");
    }
    };
    obj1.show();
    }
    }
    //one way to implement functional interface
    class B implements A{
    @Override
    public void show(){
    System.out.println("Hello");
    }
    }
    //specify it is functional interface
    @FunctionalInterface //we use this annotation to specify it is functional interface
    interface A{
    void show();
    //void run(); //this will give error as it is a functional interface you cannot write two abstract method in this
    }
    Github repo : github.com/nav...
    Java:- bit.ly/JavaUde...
    Spring:- bit.ly/SpringU...
    More Learning :
    Java :- bit.ly/3x6rr0N
    Python :- bit.ly/3GRc7JX
    Django :- bit.ly/3MmoJK6
    JavaScript :- bit.ly/3tiAlHo
    Node JS :- bit.ly/3GT4liq
    Rest Api :-bit.ly/3MjhZwt
    Servlet :- bit.ly/3Q7eA7k
    Spring Framework :- bit.ly/3xi7buh
    Design Patterns in Java :- bit.ly/3MocXiq
    Docker :- bit.ly/3xjWzLA
    Blockchain Tutorial :- bit.ly/3NSbOkc
    Corda Tutorial:- bit.ly/3thbUKa
    Hyperledger Fabric :- bit.ly/38RZCRB
    NoSQL Tutorial :- bit.ly/3aJpRuc
    Mysql Tutorial :- bit.ly/3thpr4L
    Data Structures using Java :- bit.ly/3MuJa7S
    Git Tutorial :- bit.ly/3NXyCPu
    Donation:
    PayPal Id : navinreddy20
    www.telusko.com

Комментарии • 18

  • @gerdsfargen6687
    @gerdsfargen6687 Год назад +9

    Telusko is the Java man!

  • @simizara
    @simizara Месяц назад

    A obj1 = new A(){
    @Override
    public void show(){
    System.out.println("Hello");
    }
    };
    obj1.show();
    }
    }
    I am note getting the output, it is showing Type A is already defined..pls help

  • @md.ikramulislam9708
    @md.ikramulislam9708 19 дней назад

    it should be after #75

  • @ritusinghthakur9637
    @ritusinghthakur9637 2 месяца назад

    I have doubt ....
    But interface name not create object, class name make object , interface only object reference
    I mean A obj=new A() not right...
    Object banane ke leye class banani padegi

  • @afifkhaja
    @afifkhaja 11 месяцев назад +1

    Thanks for this! Perfectly explained

  • @v.kowsalyavelmurugan760
    @v.kowsalyavelmurugan760 7 месяцев назад +1

    We already have interface... Then why we are going to functional interface?

    • @anshujacob3304
      @anshujacob3304 7 месяцев назад +1

      It’s used to provide implementations through lambda expressions which would reduce the number of codes in a program. There are many functional interfaces which we use in programming like runnable interface is a functional interface so we can use lambda expression to provide implementation for the run function.

  • @samartajshaikh2601
    @samartajshaikh2601 10 месяцев назад +1

    That was real cliffhanger video.

  • @balapadma-tn1un
    @balapadma-tn1un 2 месяца назад

    why do they introduce functional interface in java 8 and tell me that one

  • @pamu
    @pamu Год назад +3

    "we want errors, right?" 😅 ... well, just in this case.... 😉

  • @jyotiradityatripathi6095
    @jyotiradityatripathi6095 4 месяца назад

  • @ShubhamSingodiya-o4h
    @ShubhamSingodiya-o4h Год назад +1

    what's this x: ?

    • @premgajare7600
      @premgajare7600 Год назад +2

      It means that the string to be printed.
      It is sign that tells whether you want to print string (for example : system.out.println("hello world");) or a variable or both.
      If you are new to java and vs code, don't worry about that.

    • @benitonfernando2645
      @benitonfernando2645 Год назад +1

      The "x:" is inserted by the IDE. We don't explicitly write them but the IDE inserts it automatically. Just to make us understand better. There are many scenarios like this where the IDE auto inserts keys which can be ignored.

  • @shraddhapawar5674
    @shraddhapawar5674 Год назад

    This is jdk11?

    • @yuv09
      @yuv09 Год назад +1

      JDK 17 LTS

  • @CvetanSimsic
    @CvetanSimsic 10 месяцев назад +2

    Someone should tell you not to teach Java and write method brackets on new lines. This is not C#.

  • @arjunthazhath
    @arjunthazhath Год назад +2

    hELLO SIR, I LOVE UR CLASSES. WOULD BE GREAT IF WE HAD SOME BACKGROUND MUSIC. WOULD BE ENGAGING TO WATCH