8.22 Interface in Java 8 Default , Static Methods | New features

Поділитися
Вставка
  • Опубліковано 2 гру 2024

КОМЕНТАРІ • 525

  • @fernandomora1963
    @fernandomora1963 5 років тому +230

    I watched two hours of Navin's tutorials and I'm just trying to get a refresher on Java. I'm so upset that he wasn't around the years when i was learning Java. If you are starting to learn Java and come across Navin's playlist... it's like you've discovered a gold mine. Now i'm basically watching the rest of his tutorials because he's so clear and fun to watch.

    • @bhavik.kothari
      @bhavik.kothari 4 роки тому +1

      I totally agree

    • @nithyashreenaidu8357
      @nithyashreenaidu8357 4 роки тому

      yeah he is diamond

    • @sanketdhamala8456
      @sanketdhamala8456 4 роки тому

      @@bhavik.kothari Totally agreed. Alot of videos on programming are either extremely boring to listen to or they're not as concise. Thank you Navin

    • @universalstarcreations7297
      @universalstarcreations7297 3 роки тому

      But these videos are of older versions of Java. Many advancements took place in these days. If those advancements are too covered it'll be more helpful for the fresher's now

    • @jesseduncan1140
      @jesseduncan1140 3 роки тому

      I dont mean to be off topic but does someone know of a tool to get back into an instagram account?
      I somehow forgot my login password. I would appreciate any tips you can offer me.

  • @AmitKumaarrr
    @AmitKumaarrr 6 років тому +19

    The way you have explained I have never seen such an easy tutorial about basics of Lambda express in Java.

  • @adriano.santana
    @adriano.santana 5 років тому +9

    Been trying to learn Java through books, udemy courses, articles, and so far you're the best teacher I've found. Thanks,really. I've been stuck with some subjects like interfaces and your videos are clearing my doubts.

  • @premkumareaswaran6875
    @premkumareaswaran6875 4 роки тому +12

    Thanks for this amazing tutorial Navin. You are saviour. Just would to add something. If there are two interfaces which define the same method (Ex: show()), then the class that implements these two interfaces does not always have to define the same method. Instead, it can use the "super" keyword like below which will also work.
    .super.show();
    Nonetheless, thanks a lot once again. You are an amazing teacher.

    • @saurav0203srivastav
      @saurav0203srivastav Рік тому

      Hi Prem, actually in this case you have to define the show() method in your class and then you can choose to call show() method in your definition by using InterfaceName.super.show();

  • @himanshidhamija9524
    @himanshidhamija9524 4 роки тому +2

    I am watching this years later and still so relevant,its such a great quality content. I have not found anyone explaining java and making is to easy to understand and learn.Thank you for your hard work sir. Its really helpful

  • @MetaBlueAvatar
    @MetaBlueAvatar 3 роки тому +1

    This is the most comprehensive video I have ever seen on default and static keywords. So many details listed out with such a simple and evenly paced delivery! You, sir, are simply amazing!

  • @JayPatel12928
    @JayPatel12928 6 років тому +26

    This is a gold quality information, take a bow Navin! I know this because I have been here for a while now and having worked with Java for 5ish years, I have rarely found such good quality videos. Pure Gold!

  • @subashchokkalingam6312
    @subashchokkalingam6312 4 роки тому +1

    I was watching your videos past 3 days. i was really immpressed and appreciate your efforts to explaining the difficult concept iin the simple way. I was quit out of IT industry (exp 14 years) around 4 years back and starting doing business in the different verticle (Non-IT) but after seeing your videos got an interest to work again in IT and come back to work in Java with latest technologies.Since you are there for me to give technologies in the simplest way. I recalled all my 14 years of experience in 2 days. Really appreciate for your effort on this. Salute to Naveen. Thanks Subash C

  • @6977202865
    @6977202865 5 років тому +2

    your making everything dead easy to be understood with your explanations!!! you are amazing!! thank you very very much!!!!

  • @sneha_d_mystery_princess
    @sneha_d_mystery_princess 5 років тому

    Navin sir... I must say... ur explanation is too good... u make things easy... by taking the exact appropriate cases... Thank you so much...

  • @watchb4udie398
    @watchb4udie398 4 роки тому +5

    it was nice listening so for and thank you for putting your effort in teaching us.

  • @prashantshekharrathore4661
    @prashantshekharrathore4661 2 роки тому

    Sir I cant stop watching your videos....I open laptop to learn some DSA and end up watching your videos one by one. Damn Naveen sir your are awesome. God bless you. :D

  • @jitheshss90
    @jitheshss90 2 роки тому

    Perfect tutorial. If anybody has to know about the Default Method in java 8. Please go through this video and I recommend this.

  • @elamurugup352
    @elamurugup352 3 роки тому +5

    Thanks for this session Naveen. Jsut want to be more clear,Could you exactly differentiate the difference between abstract class and interface since both are defining methods in java 8?

  • @rasul_dude
    @rasul_dude 4 роки тому +1

    Your tutorial is not so long and also not so short. Your tutorial are really perfect

  • @nagapradeepvankayala7301
    @nagapradeepvankayala7301 2 роки тому

    Navin is Awesome, no matter how long the video size is, my same interest levels would continue throughout the video from starting till ending, excellent explanation skills he has...Yes, Navin is a Gold mine, Diamond, and even more than that. We are all so lucky to have him. Love you brother :), I wish God bless you with lots of energy, skills, and continued enthusiasm towards sharing knowledge like this

  • @naveenkondamuri4946
    @naveenkondamuri4946 3 роки тому +1

    Thank you so much Navin for the wonderful explanation. If possible, please provide sessions on Spring Batch, and Microservices.

  • @prameelabanda1568
    @prameelabanda1568 6 років тому +29

    HI Navin,
    I kept watching and learning through your tutorials. Your way of teaching is good.
    My only suggestion is , please use real world example for every concepts which helps to understand quick and remember the concepts for long go :)

  • @balramkewat9576
    @balramkewat9576 3 роки тому

    11:14if we implement both interface in one class .. 11:15 define the show(); in Class C,
    then which method should call??
    class C method, or interface I's method or interface J's method

  • @vivekmerugu6711
    @vivekmerugu6711 4 роки тому

    Your are explaining the concepts very beautifully and with ease. The way you explained the concepts with real time examples are really awesome.

  • @shivaramkrishnadurgi4253
    @shivaramkrishnadurgi4253 3 роки тому

    Amazing teaching Naveen reddy...so crystal clear...

  • @priyadarshiniMG
    @priyadarshiniMG 5 місяців тому

    Very well explained the concepts and difference between the interface and abstract class with perfect example and explanation in an easy way. Thq so much dear👍👏🤗

  • @parth191079
    @parth191079 7 років тому +30

    Hi Navin,
    I became your fan and a "chela" after this video! Awesome work, sir! Thanks a lot!!

    • @sureshsharma1808
      @sureshsharma1808 7 років тому +1

      Yes. same here. He doesn't create complexity and very centric to make other understand. Great Job Sir.

    • @SirThanksalot_1
      @SirThanksalot_1 5 років тому

      did somebody say 'Thanksalot'?

  • @himanshushekhar8551
    @himanshushekhar8551 7 років тому +2

    u r such a amazing teacher sir..you have clear my all concept..thank you sir..

  • @ankitsaxenamusic
    @ankitsaxenamusic 7 років тому +2

    You're amazing.. Hats off to you Naveen. No book can describe with such an ease. Kudos.. Keep on posting more videos :)

  • @jaserq
    @jaserq 4 роки тому +2

    He is the best with his style.! And his signature is "HI ALIENS" :)

  • @swaminaidu9454
    @swaminaidu9454 4 роки тому

    You are the reason behind my earning in software field.thanks a ton.keep doing videos for geeks like me.Waiting for more videos

  • @sumanjogi614
    @sumanjogi614 3 роки тому

    It feels so good to learn from you!! I have no words to explain it. Others will understand for sure!!!

  • @sumitsouravamohanty8935
    @sumitsouravamohanty8935 5 років тому +1

    At 14:35 can you please tell me how you know this "Third Rule " in java 8 .. Have you google it or explore it on your own..

  • @erikmueller5622
    @erikmueller5622 5 років тому

    An interface is a way of grouping classes. The reason for this is that any class that implements that interface must "do" all the methods that are written in that interface. So if there is an interface called "animal" which has methods: eat, sleep, walk, run, jump, then we have a bunch of classes for different types of animals, we would "group" all the different animal classes together by making them all implement the interface which means they must all "do" the methods in the interface, because those methods are common to them all. If that sounds exactly like inheritance with an abstract parent class that's because it is. The reason that an interfaces are used instead of regular abstract class inheritance is because in Java a class can only have one parent class but can many interfaces interfaces. If a class could have multiple parent classes then there would be no point in interfaces.

  • @sebastiancapone3284
    @sebastiancapone3284 5 років тому +1

    I have looked at several tutorials ... I consider myself a perfectionist and I like to learn, not only to know a programming language from above without going into the details. By your way of explaining I can see the passion you give to your videos and when I look at them, I have the security of learning, because you go to the smallest detail. You are very perfectionist and this is really appreciated ... There is no other course, which has caught me like this ... I really appreciate it.

  • @007ayansinha
    @007ayansinha 5 років тому +9

    I just love the way he starts with the word “welcome back aliens” 🤓

  • @rohn3711
    @rohn3711 Рік тому

    14:07 what if we remove 'public' from class A 's show() method and tried implementing 'I' and extending 'A' ? Is this priority given on the basis of methods access modifiers ? or on the basis of class or interface?

  • @HarishV-q1i
    @HarishV-q1i Рік тому

    i have doubt about 12:00 bcoz you created two interfaces and one class. and then you wrote a show method and you said we must define show method also in C class, then we ran program and which show is called from class to interface I or J?

  • @Harsh_r_mh09
    @Harsh_r_mh09 3 роки тому +1

    Great level of teaching!

  • @tranhai5146
    @tranhai5146 3 роки тому

    Your Java 8 - Interface lession is perfect.

  • @Spider-Man_67
    @Spider-Man_67 4 роки тому +1

    Thank a lot sir for explaining it in a pretty simple way.

  • @deepanshubabbar9324
    @deepanshubabbar9324 3 роки тому

    Thanks a lot naveen reddy for these tutorials. You are one of my favourites when it comes to programming tutorials. The tutorials are perfect.

  • @iccherherbarium9688
    @iccherherbarium9688 3 роки тому

    Then what is the profit of defining show in interface I and J ? Referring to third rule example 14:20

  • @VishalRaoOnYouTube
    @VishalRaoOnYouTube 4 роки тому +3

    11:51 I think that even when you have the diamond problem, you can still invoke the interface's default method from the class definition by calling either I.super.show() or J.super.show() Let me know if that sounds correct. stackoverflow.com/questions/19976487/explicitly-calling-a-default-method-in-java

    • @FaycalAZIB
      @FaycalAZIB 4 роки тому

      I've explain this point in my course

    • @prithvik8448
      @prithvik8448 2 роки тому

      Exactly that's what am thinking 🤔

  • @kalyankumargudla6027
    @kalyankumargudla6027 4 роки тому +2

    Thanks you for you videos .
    Have question
    When our class ‘C’ implement ‘I’ and ‘J’ as you said we should override the common method to avoid errors .
    When we use third party libraries , if our class implement two interfaces if both having same method in there interfaces as per tutorial we should override common method , but here we don’t know the business logic of interfaces common method .
    Could you pls explain this

  • @khadarzone
    @khadarzone 8 років тому +1

    Good one Navin... Very helpful in understanding java 8 concepts..

  • @chaturadedigamuwa969
    @chaturadedigamuwa969 2 роки тому

    Navin is the best guy to learn java. Thank you so much

  • @anuragverma9519
    @anuragverma9519 6 років тому +4

    great explanation for interview

  • @MahendraBabuRajendran
    @MahendraBabuRajendran 6 років тому +2

    All C++ concepts are coming back in Java!
    Those who worked with C++ will find this easy! :)

  • @De0D
    @De0D 5 років тому +4

    telusko more powerfull than class ,class more powerfull than interface...done ive said it

  • @rajendralella6956
    @rajendralella6956 4 роки тому

    Very well explained with examples, simply brilliant

  • @gunavanthamgowda669
    @gunavanthamgowda669 7 місяців тому +1

    Hi Sir, I love the way you explain, at last you told we can access static method of the interface n main like (I.show()) method without creating object of interface I. But is it mandatory to implement the interface? could you please elaborate static methods.

  • @chungwm
    @chungwm 4 роки тому

    The word hidden by [Telusko] at 14:20 is "ThirdRules"

  • @vijaykumarreddyt3287
    @vijaykumarreddyt3287 Рік тому

    Navin Reddy, You teach Great

  • @truptigandhi891
    @truptigandhi891 4 роки тому

    U made this concept so easy.....👍👍

  • @sasmitamoharana39
    @sasmitamoharana39 5 років тому +6

    Hi Navin,
    Thank you and nicely you explained, I have one doubt, what is the difference between abstract class and interface in Java 1.8?

    • @logic_master950
      @logic_master950 5 років тому

      Interface only built with abstract methods(pure virtual functions). No defined method allowed in interface.

    • @logic_master950
      @logic_master950 5 років тому

      Interface only can have abstract method

    • @DR-pi9vk
      @DR-pi9vk 5 років тому

      @@logic_master950 But that s not true anymore since 1.8. That s what he explained in this video. I still dont see a difference now between those two classes

    • @logic_master950
      @logic_master950 5 років тому

      @@DR-pi9vk thanks a lot , dear

  • @sindhusudhakaran1731
    @sindhusudhakaran1731 4 роки тому

    Thank you so much Navin for this video .. it's very helpful

  • @meena7222
    @meena7222 3 роки тому

    The mention of function declarations in C was helpful.

  • @alpesh003
    @alpesh003 3 роки тому

    🙏 This is awesome! Please dont stop. Hope it benefits you a lot.

  • @deeps2111
    @deeps2111 4 роки тому

    Very well explained. Thanks Navin

  • @ajaydhiman2368
    @ajaydhiman2368 4 роки тому

    want to add 1 point here, If class C implements both the Interface I & J then its not necessary for class C to give the definition of static method (provided you are not calling it in your class C) but its necessary to for class C to give the definition of default methods (even though your are not calling it in your class C)

  • @karthikeyat9386
    @karthikeyat9386 7 років тому

    I think you have deviated from the actual point. At around 3:00 you were saying that defaults methods are introduced so that we can use the new features like Stream API, etc.. But you deviated from that point and talked on rules of default methods.
    Can you please bring clarity on how Java developers benefit in using default methods to use new features of Java8
    thank you.

  • @AnshumanSharmadev
    @AnshumanSharmadev 3 роки тому

    Wow! Amazing! Loved it! Thank you!

  • @kartheek.g3667
    @kartheek.g3667 8 років тому +3

    thank's with this vedio I got some idea of interface

  • @prasadbojanapu5093
    @prasadbojanapu5093 8 років тому +1

    Its so good for us, please explain all new features in java 8, if it is having more.

  • @SharadMeghnathi
    @SharadMeghnathi 5 років тому

    I have one doubt in last few mins. You said at 15:50, that if we define method inside interface and the same method is override in the implementing class it won't work. I think you are wrong here. It will call local method and won't generate error.
    Correct me if I didn't understand of taken it wrong.

    • @charanteja4619
      @charanteja4619 4 роки тому

      he mentioned it will take from class method rather than interface

  • @hetalrachh5665
    @hetalrachh5665 4 роки тому

    Really useful content !! Thanks for your videos.

  • @romanmotovilov129
    @romanmotovilov129 4 роки тому +1

    Thank you, sir, for a good lesson!!!

  • @themodestai9603
    @themodestai9603 4 роки тому

    Best teacher ever!

  • @bodduanilkumar7783
    @bodduanilkumar7783 5 років тому

    Hi Navin sir,
    Example u explained using third rule is always calling first interface rather than the class which is extended

  • @aashishkumarchauhan8057
    @aashishkumarchauhan8057 5 років тому +4

    Hi Navin,
    Thanks for explaining in such a good way. I have one doubt about both abstract class and interface can have methods with implementation in Java 8. Then what is difference between both ?
    Where should we use abstract class and where we can go with interfaces ?

    • @justforjava192
      @justforjava192 4 роки тому

      You obviously can define methods in an interface, but it isn't *designed* for that. Do it if you have no other choice, (just like List did it for backward compatibility). Interfaces are designed for 100% abstraction. They, moreover don't tell what your class *is, but rather, what it can do (which is why we name them with an adjective rather than a noun).* Realize an interface doesn't affect its implementor much. You could easily retrofit your class to implement or unimpliment an interface, without changing the existing implementation (even if it's already a subclass, due to multiple inheritance). This is impossible with an abstract class, as their subclasses hugely rely on them. Hence, when you have to implement methods, and your subclasses rely on their parent's implementation, choose an abstract class. Else if you wanna just define the behavior of a class, choose an interface.

    • @prashantaarya3852
      @prashantaarya3852 4 роки тому

      No doubt video is helpful but not complete. For that we can use show(){A.super.show(); B.super.show();} whichever implementation you can call.

    • @divyad9144
      @divyad9144 3 роки тому

      When we doesn't know any implementation at all, we only have requirement specification then in such cases we go for interface. And when we know implementation but not completely (partial implementation) then we go for abstract class

  • @mayankmoolchandani7976
    @mayankmoolchandani7976 6 років тому +2

    sir you deserve an Oscar for the way of your teaching. THANKYOU

  • @shashgo
    @shashgo 7 років тому +1

    Navin, So I understand that up until 1.7, we can do multiple inheritance with interfaces because interfaces dont implement methods. And Im assuming that the answer to why we cannot inherit from mutiple classes, even if the classes are abstract is that these abstract classes CAN all implement the same methods. Coming to Java 1.8, what is the benefit of making it possible to implement methods in interfaces? If we can inherit from multiple interfaces that all implement the same methods, and then have to implement the method again in the child class, then what is the benefit. We have to implement the same method thrice. Also this is like inheriting from multiple classes, so what is the reason for this new interface definition?

  • @half-blood-prince
    @half-blood-prince 6 років тому

    Your way of explaining things, and sentence construction is great bro.
    keep up the good work.

  • @bhavyakumarpanchotiya8254
    @bhavyakumarpanchotiya8254 4 роки тому

    Good Video sir and thanks for provide some information related to java 8

  • @vijayakumarvj
    @vijayakumarvj 6 років тому

    excellent video, pretty clear.. I don't know why 28 dislikes

  • @rtheame4704
    @rtheame4704 4 роки тому

    Really explained well. Thank You. Can we use super keyword to solve default methods diamond problem

  • @rovsenhuseynov8368
    @rovsenhuseynov8368 4 роки тому

    Great explanation, valuable info. Thank you Navin!

  • @arpitanand6534
    @arpitanand6534 4 роки тому

    You rock Navin, I am your fan

  • @dexterdenmark5988
    @dexterdenmark5988 4 роки тому

    I like this lecture Very much! Thank you !

  • @varunsharma264
    @varunsharma264 4 роки тому

    Sir! Your Tutorials are really helpful. Thanks

    • @FaycalAZIB
      @FaycalAZIB 4 роки тому

      check my course about java 8 :)

  • @preetsharma9585
    @preetsharma9585 8 років тому +4

    1) Can we use default methods in abstract class or simple class??
    2) As now Interfaces are not 100% abstract, what difference is left now between abstract classes and interfaces?

    • @vakho30
      @vakho30 7 років тому +2

      2) Basically, abstract classes allow you to define instance variables whereas interfaces don't. Abstract class can also extend other abstract class. There are other differences (which I am too lazy to think about :d) 1) Yes, you can implements an interface which has default method and use it in abstract and concrete class.

  • @sreelekhapola8813
    @sreelekhapola8813 3 роки тому

    In this you explained like when we have two interface with same method , in that case we have to override that method in the class. after that i didn't understood are we calling the implement methods or what we are doing after overriding

  • @SanthoshKumar-rh4lh
    @SanthoshKumar-rh4lh 6 років тому +1

    Hi sir,
    What is the main advantage of this feature? Will this effect old version implementation .

  • @rubanprakash8088
    @rubanprakash8088 7 років тому

    Hi Naveen you are just awesome... god bless you and keep uploading videos it really helps me. thanks a lot.

  • @nishant5519
    @nishant5519 6 років тому +5

    At 3.10 you said stream() method is introduced in List interface from Java 1.8
    I think this is wrong. There is nothing like stream() method in List interface

    • @rubybaksh2234
      @rubybaksh2234 4 роки тому

      We have stream() in Collection interface in java 8

  • @krishnamoorthynatarajan6903
    @krishnamoorthynatarajan6903 6 років тому

    My question is
    say
    // as said in e.g.,
    inteface I
    {
    default boolean equals(Object o)
    {
    return true;
    }
    class Object {
    public boolean equals(Object obj) {
    return (this == obj);
    }
    }
    // it is extending object class by default
    class A implements I
    {
    }
    class B
    {
    A obj = new A();
    obj.show(); // what will happen here is, as said in the video, class methods overtakes Interface default methods. this will call / // //Object.equals() only.
    }
    So potentially we can allow it right ?

  • @pradnyapotdar7768
    @pradnyapotdar7768 6 років тому +1

    Hi Navin. Thanks for info. But can we add static main method in interface. If yes then how to execute it ?

  • @anirudhgahlot6361
    @anirudhgahlot6361 6 років тому

    Excellent session, cleared many concepts.

  • @craftyrouze
    @craftyrouze 2 роки тому

    Thank you for a very good explanation. I have been using default methods a lot, but never occured to me there are limitations

  • @saurabhtyagi7379
    @saurabhtyagi7379 5 років тому

    Waaaah too good you should have been my professor in college time 🤗

  • @subashboss100
    @subashboss100 4 роки тому

    wonderful, thanks a lot. One question, what is the main use of static methods in interface, I just like to know real time example for the same

  • @rajkapoor944
    @rajkapoor944 4 роки тому

    really good man - highly rate your great explanation. Thanks

  • @RamanKumar-rr9wi
    @RamanKumar-rr9wi 7 років тому +5

    useful. but still m not able to understand .. what's the difference between abstract class and interface... basically want to know when to use abstract class and when to use interfaces...?

    • @shankeywanderlust
      @shankeywanderlust 6 років тому +1

      Interface we can use when we want strict implementations like overriding all the methods in the implementation class but if we wish to have some special characteristics only and not all the methods then we can use abstract method. When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.

  • @foxhound4829
    @foxhound4829 8 років тому

    Very cool explanation with some very good examples. Keep it up!

  • @Efocusto
    @Efocusto 3 роки тому

    wonderful work big like

  • @amitghosh6199
    @amitghosh6199 3 роки тому +2

    can you explain the purpose of Abstract class in java8 when we have interface with default method. would appreciate if you comment or create a video on this. Thanks for providing awesome learning experience for all of us.

    • @scars707
      @scars707 2 роки тому

      and why do we need to implement and make our own method in the class c ?

  • @ABCDEFGHIJKLMN326
    @ABCDEFGHIJKLMN326 8 років тому

    - Sir..., There's a little confusion... Don't we have to write a keyword *default* before static void show() inside Interface I (with reference to the discussed example) as you told earlier we have to use default keyword while defining method inside interface. Looking forward for your reply....

  • @priyagawai6963
    @priyagawai6963 3 роки тому

    Thank you sir, it's really helpful. Very well explained.

  • @AddisEngine
    @AddisEngine 4 роки тому

    Great explanation !

  • @neetigupta5468
    @neetigupta5468 5 років тому +1

    loved it . Thanks Navin

  • @princevijaypratap6025
    @princevijaypratap6025 6 років тому

    sir u have explained very well that why we should have a default method in java 1.8 interface but please can u elaborate the significance of having the static method in interface too with any real time scenario or example like u have explained for default one because I don't see any practical requirement of doing that.

  • @bksolvent1
    @bksolvent1 8 років тому

    Good work Mr Naveen Sir

  • @AmbujRajput
    @AmbujRajput 6 років тому

    One of the best video of your channel. Thanks :)