Java Interface Tutorial #78

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ธ.ค. 2024

ความคิดเห็น • 342

  • @alexlorenlee
    @alexlorenlee  ปีที่แล้ว +5

    If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h

  • @xdragonflame6563
    @xdragonflame6563 5 ปีที่แล้ว +527

    You are literally the only youtuber that I understand in the subject of Java. College professors are very vague and don't teach well. I am sure you will become a big channel someday. Thank you for helping me and thousands of other people learn java.

    • @alexlorenlee
      @alexlorenlee  5 ปีที่แล้ว +33

      xDragonFlame thanks for the kind words :) you’re welcome!!

    • @jamesbrooks9321
      @jamesbrooks9321 4 ปีที่แล้ว +10

      I don’t know why it’s so hard to find more java instructors, there are plenty of good JavaScript and php videos but when it comes to java no one is doing this

    • @leif1075
      @leif1075 4 ปีที่แล้ว +1

      @@alexlorenlee Cam you just add the interface with some code so that you don't have to add each method manually one by one like you had to with fill and pour out?

    • @simiiv5021
      @simiiv5021 4 ปีที่แล้ว +4

      Exactly what I was gonna comment. Alex, you are amazing!

    • @TheKittu29
      @TheKittu29 3 ปีที่แล้ว +1

      Actually every method in Interface is public and abstract. Abstract methods does not contain method body. We need to implement the abstract methods by using child classes. Here InterfaceExample is the child class of waterBottleInterface(interface).

  • @latedeveloper7836
    @latedeveloper7836 3 ปีที่แล้ว +47

    0:56 Definition of an interface (an outline for a class) and implementation
    2:10 Outline of what the example interface can do (attributes)
    2:30 Implementing the interface
    3:15 Implementing the example method from the interface (fillUp)
    4:12 Use an interface when you want to use an example outline/template of a class that you don't need/want to create
    5:20 What happens when we implement an interface

  • @turuus5215
    @turuus5215 2 ปีที่แล้ว +27

    IMO, "Alex Lee" and "Coding with John" are the best 2 channels for Java learners. They teach infinitely better than most college professors.

  • @asleyeizmendiz331
    @asleyeizmendiz331 4 ปีที่แล้ว +248

    I would love that you would have said :
    All methods in an interface are abstract.
    All methods in an interface are automatically public. The keyword public does not appear.
    Interfaces do not have instance variables because no objects of the interface type can be created!
    Any variables declared in an interface are automatically public, static, and final (i.e. constants). For that reason, these keywords should not appear in the declaration.
    for example.

    • @NuanDaa
      @NuanDaa 2 ปีที่แล้ว +7

      Good details. Thanks.

    • @knanzeynalov7133
      @knanzeynalov7133 2 ปีที่แล้ว +1

      thanks for additional information.

    • @howled0
      @howled0 9 หลายเดือนก่อน

      very late but thanks for adding this :)

  • @deziqn-_-beasto720
    @deziqn-_-beasto720 4 ปีที่แล้ว +54

    Thank you sir. My professor was rambling for 45 minutes and couldn’t explain what you explained in 6 minutes

    • @jamesmonto9562
      @jamesmonto9562 3 ปีที่แล้ว +4

      Best teachers will be online. Just wait. The future will pave the way. I can’t wait for the school system to break down and we get into real learning.
      Sovereign individual will come.

    • @CookieCutVids
      @CookieCutVids 3 ปีที่แล้ว +1

      @@jamesmonto9562 amen brother

  • @HugoCornellier
    @HugoCornellier 4 ปีที่แล้ว +122

    Your videos are the best Java videos on TH-cam, thank you so much!

    • @JewelFornillas
      @JewelFornillas 4 ปีที่แล้ว +1

      I agree!

    • @Qwertyiopljgrd
      @Qwertyiopljgrd 2 ปีที่แล้ว +1

      im not agree

    • @NuanDaa
      @NuanDaa 2 ปีที่แล้ว

      @@Qwertyiopljgrd I am not agree too

    • @shadowfortuna1381
      @shadowfortuna1381 8 หลายเดือนก่อน

      ​@@NuanDaa, so tell who is better

    • @shadowfortuna1381
      @shadowfortuna1381 8 หลายเดือนก่อน

      ​@@Qwertyiopljgrd, so tell me who is better?

  • @blitzbladerr9035
    @blitzbladerr9035 4 ปีที่แล้ว +12

    It all clicked when you said an interface it more of a guideline or template. It is not necessary but more useful for setting up a new class that 'inherits' variables and needs these methods defined in its own class.
    Thank you

  • @aimannajah3165
    @aimannajah3165 5 ปีที่แล้ว +18

    Man you are the GOAT! Thank you so much for your help!!!!!! You really make everything far more clear and simpler than I thought it was

  • @clareadwards1318
    @clareadwards1318 2 ปีที่แล้ว +1

    You know what I really appreciate is that sometimes I feel really dumb for not understanding things from the beginning and when you said you had no idea why interfaces were used till after college it kinda gave me a little support.Thank you for this channel and your content Alex

  • @ahrarcorson6452
    @ahrarcorson6452 5 ปีที่แล้ว +39

    Perfect! missed my lecture about this, you covered it in less than 10 mins for me to understand, appreciate the help man!

  • @bhargavmehta97
    @bhargavmehta97 3 ปีที่แล้ว +1

    You explain much better than the books and other people on the channel. Short & straight to the point.

  • @RippedMoFuCk
    @RippedMoFuCk 3 ปีที่แล้ว +21

    Many smart students who feel like abused by their terrible teachers come here and have found you, myself included. And thank you for existing. It's great having a place where you know the comments is filled of like minded people going through exactly what you are, and a teacher who knows how bad teachers generally are at teaching strangely simple but over-complicated concepts.

  • @mohamedelkhallifi1910
    @mohamedelkhallifi1910 11 หลายเดือนก่อน

    Welcome back! I've been following you since 2021, and I have to admit, hearing that you were taking a break from making new Java videos made me a bit sad. However, seeing you back in action now brings so much joy! I absolutely love your videos and the way you effortlessly explain complex concepts.
    I appreciate your content.

  • @dmbelafan
    @dmbelafan 4 ปีที่แล้ว

    Just echoing the rest of the comment section, but as a complete java novice, the interface concept was the first rudimentary concept that just didn't immediately click for me. Wasted far too long trying to figure it out on my own, thank you so much for this video. Clear, quick, and well delivered. Excuse me while I watch all your other content. =)

  • @so9032
    @so9032 4 ปีที่แล้ว +2

    I tried to learn Java with many different videos and had hard time understanding it. You explain everything so easy! I learned so much from you. Thank you so much

  • @kevinadrianperaza3179
    @kevinadrianperaza3179 5 ปีที่แล้ว +10

    Keep it up with the good work man, you are a college savior, really enjoy your content

  • @westernpigeon
    @westernpigeon 2 ปีที่แล้ว +2

    i know im late but dude your videos are awesome. I'm learning Java at my bootcamp and I've watched like 6 of your videos and they all helped tremendously! everytime im watching your videos it feels like a close friend is explaining these topics to me lol thank you!!!

  • @ebodshojaei4967
    @ebodshojaei4967 ปีที่แล้ว +1

    You did an excellent job explaining. “An interface is an outline of a class”. Easy to remember. Thanks!

  • @jamikemichelohia2615
    @jamikemichelohia2615 3 ปีที่แล้ว

    When it comes to Python, I TH-cam whatever i want to learn, that are bit complex and it pops up.
    But for Java not the case, rare videos on youtube.
    Thank god i found this guy

  • @Rayshaun1519
    @Rayshaun1519 3 ปีที่แล้ว +2

    I only watch your videos. You've helped me with a lot of my assignments. Thank you so much, Alex!

  • @veer7005
    @veer7005 ปีที่แล้ว

    Thanks for keeping these videos up, mid term in a few hours and I've been going over your videos since last night. Thank you.

  • @ChunkySalsa_BSU
    @ChunkySalsa_BSU 3 ปีที่แล้ว +3

    Love this! No extra stuff, just straight to the point! Thank you.

  • @Ap-fl2zi
    @Ap-fl2zi 5 ปีที่แล้ว +10

    Thank you! Definitely needed a refresher on this! I have my first interview next week

  • @anapeo
    @anapeo 4 ปีที่แล้ว +2

    I'm taking AP Comp Sci right now and your videos really do help. Thank you!

  • @Uzairajmal05
    @Uzairajmal05 2 ปีที่แล้ว

    You are literally the only youtuber that I understand in the subject of Java

  • @asimenibhavya6423
    @asimenibhavya6423 4 ปีที่แล้ว +1

    I feel lucky to end up here and brushing up my Java knowledge (Y) Thank you :)

  • @abdeselamselami4532
    @abdeselamselami4532 5 ปีที่แล้ว +3

    Thanks a lot Alex, for everyone the short-cut of System.out.println() is type sysout + hit buttons ctrl+space.

  • @Luckyme8556
    @Luckyme8556 4 ปีที่แล้ว

    What this guy does is unbelievable...He makes things too easy to be true

  • @ronakpatil1
    @ronakpatil1 3 ปีที่แล้ว

    This is some real content bruhhh
    I was not able to understand this topic until this video
    Thanks.

  • @ayshafarheen4992
    @ayshafarheen4992 4 ปีที่แล้ว

    literally the number one person I come to for java and for good reason. Thank you :')

  • @stone_pilot
    @stone_pilot 4 ปีที่แล้ว

    Thank you so much. You make learning Java so painless and even fun. I dread reading boring and horrible explanations, and yours are nothing of the sort! It makes my time feel worthwhile.

  • @aliciagates1957
    @aliciagates1957 4 ปีที่แล้ว +2

    Alex thank you so much for all the wonderful videos you have helped me so much on topics that I only halfway understand. After watching your videos I always feel like a more confident beginning coder

  • @karimnabilsi3787
    @karimnabilsi3787 4 ปีที่แล้ว +1

    Thank you so much, Alex, you are a great person to come back to when not understanding things about coding, although you can dive deeper into these things in other videos, I am still thankful that you are here to help. I hope one day you become a well-known channel that many people come for help to.

  • @haritharajeev7108
    @haritharajeev7108 3 ปีที่แล้ว +1

    Honestly,thank you sooo much......you are just saving my life in each video you make ...soooooooo😂😂do what u do ❤️❤️❤️❤️❤️

  • @TheGbossTV
    @TheGbossTV 5 ปีที่แล้ว +6

    Thanks you so much man I appreciate it. In college (I live in Portugal) my teacher is spanish and doesn’t speak portuguese so I can’t understand jack shit of what he’s saying. Thank god you exist

  • @ankitwakulkar5035
    @ankitwakulkar5035 3 ปีที่แล้ว

    Your video is more helpfull to me.... U told in very easy way how to create Interface...keep doing your work

  • @sweekarbhattarai8838
    @sweekarbhattarai8838 3 ปีที่แล้ว +21

    When he said, "For firve years I had no idea what Interfaces were...."; I was like: Thank God, I am not late! xD

  • @thomasz4684
    @thomasz4684 3 ปีที่แล้ว +1

    Alex you are getting me through this degree, glad I dont have to resort to cheating and I can rely on you!

  • @dsdesai2000
    @dsdesai2000 3 ปีที่แล้ว

    Great Video
    Just some suggestions for better understanding
    Keep the main class and main method as it is.
    create one interface and another class that implements it
    Use a real example:
    Eg: The interface is a calculator and class that is implements the operations for a calculator.
    Great Video :)

  • @mysteriousunknown586
    @mysteriousunknown586 4 ปีที่แล้ว +19

    Idk man. The word "interface" sounds pretty cool to me. For some reason it reminds me of the future.

    • @darkthornplays2414
      @darkthornplays2414 3 ปีที่แล้ว +1

      "I'll create a GUI INTERFACE in Visual Basic to see if I can track an IP address"

    • @farnachause5071
      @farnachause5071 3 ปีที่แล้ว +1

      To be reminded of the future is a little paradox, isnt it?

  • @adriancaballero3889
    @adriancaballero3889 2 ปีที่แล้ว

    Thank you! Your videos are the best Java videos on youtube

  • @spicynoodles3317
    @spicynoodles3317 3 ปีที่แล้ว

    Thanks Alex! I'll be sitting for my Java certification test at the end of the summer and your videos are helping a lot!

  • @peppermintdior
    @peppermintdior 4 ปีที่แล้ว

    You make the best Java videos, never stop making them..♥

  • @unagi4254
    @unagi4254 3 ปีที่แล้ว +1

    your tutorials SAVED ME!! I appreciate you so much thank you!

  • @iwatchedthevideo7115
    @iwatchedthevideo7115 5 ปีที่แล้ว +1

    Great videos and explanations! I'm learning 10x times more than in my classes at school. Keep up the good work!

  • @jafar_u
    @jafar_u 4 ปีที่แล้ว

    You are just awesome, seriously. When I have to submit new task, I always check your videos for particular theme. I like how you go straight to the business without talking a lot about the theory. Thanks a lot! Subscirbed immediately!))

  • @GusLapchatiy
    @GusLapchatiy 3 ปีที่แล้ว

    5:49 that is what "I" in SOLID for. Interface segretation. You must tend to make more specialized versions of interfaces because implementing all the methods can be cumbersome. But you can use interface inheritance to combine interfaces if you need, and, in this case, you have specialized interfaces and combined ones as well.

  • @siddhigupta4044
    @siddhigupta4044 4 ปีที่แล้ว +2

    Lee, you're amazing!! Get back on your channel RIGHT NOWW!

  • @lexclock
    @lexclock 4 ปีที่แล้ว

    man I love ur videos u explain everything so clear and concise...I hate when there is a 20 min video with bla bla bla.... Greetings ¡

  • @mohammedfalih8713
    @mohammedfalih8713 4 ปีที่แล้ว +3

    You are awesome.. keep up the good work ❤❤🔥🔥🤟🤟

  • @Hero007ization
    @Hero007ization 2 ปีที่แล้ว

    Thanks Alex, All the way from Patna, India.

  • @professord.dragon3591
    @professord.dragon3591 4 ปีที่แล้ว +1

    You feel like you are at my level and 1000 levels above my level, at the same time. It's comforting actually.😂😂

  • @torkkk3830
    @torkkk3830 3 ปีที่แล้ว +1

    Aag Laga di 🔥🔥🔥🔥🔥

  • @brabbelback2757
    @brabbelback2757 4 ปีที่แล้ว +6

    Your keyboard sounds unbelievably satisfying!!! What is it?

    • @omemester6985
      @omemester6985 4 ปีที่แล้ว

      Probably a red or brown switch mechanical keyboard.

    • @Xx_EL_xX
      @Xx_EL_xX 4 ปีที่แล้ว

      Sorry to disagree with you. It’s definitely not a brown switch of any kind, nor do I think it’s mechanical. The soft thumpy sound is a short travel distance membrane key. Likely to be the MacBook keyboard. Could be completely wrong. Fish around his videos to see if he has any camera angle of his typing.
      Edit: th-cam.com/video/JopvFT8pv-U/w-d-xo.html Topre, damn was I wrong hahah

  • @andreaw7787
    @andreaw7787 ปีที่แล้ว

    Thank you for clearing this up, you videos are always so easy to follow keeping explanations simple and relatable.Cheers!

  • @josureamunyelan8858
    @josureamunyelan8858 2 ปีที่แล้ว

    Keep up Mr Alex, your videos are really improving my programming knowledge,,,,

  • @postnubilaphoebus96
    @postnubilaphoebus96 4 ปีที่แล้ว +4

    Although that's certainly a good explanation, I would have like if you also explained the reason behind interfaces. That is, why do we need interfaces when we have abstract classes?

    • @nickpawsey
      @nickpawsey 3 ปีที่แล้ว

      Check out this article if you are still wondering: www.tutorialspoint.com/when-to-use-an-abstract-class-and-when-to-use-an-interface-in-java

  • @drakesadosky6203
    @drakesadosky6203 ปีที่แล้ว

    Is it right to think of the interface as "This is what this type of object does"?
    The methods are listed, but left blank because each instance of the object (each time we implement the interface) may perform each method a little differently. A tea Cup may pour differently than a measuring cup. However both are Implementing the Cup interface and using the methods their own unique way.

  • @zhang8021
    @zhang8021 4 ปีที่แล้ว +1

    how about two different type of methods in interface. like void fillup() and int num();

  • @ivosrbakoski1151
    @ivosrbakoski1151 4 ปีที่แล้ว

    Awesome explanation , easy to follow and understand.
    You can grow with educational videos, because ppl can understand you well.

  • @siddhigupta4044
    @siddhigupta4044 4 ปีที่แล้ว +1

    Hi, Could you please make a video on path and classpath?

  • @ARMYRIFLES46
    @ARMYRIFLES46 4 ปีที่แล้ว +1

    Whats the difference between using an Interface and inheriting methods from an abstract class?

  • @SadnanSanim00071
    @SadnanSanim00071 4 ปีที่แล้ว

    ik this is an old video but can anyone tell me how we use the LIst interface like how is it able to take in multiple types of lists and the general use of those types of interfaces where we dont implement but use them in the code

  • @tntdogs6910
    @tntdogs6910 4 ปีที่แล้ว +5

    Difference between Abstract classes and Interfaces?
    What happens if I use an abstract class and dont implement a method, or how can I go about implementing it's default value

    • @prajilm4617
      @prajilm4617 4 ปีที่แล้ว

      Interface is nothing but a fully abstract class (abstract class in which all methods are abstract). whereas a partial abstract class is one in which some of the methods are abstract and some are concrete (have implementations). Java has a rule that a class can extend only one abstract class but a class can implement more than one interface. This can be used to simulate MULTIPLE INHERITANCE in java. Answering your second question, Subclassess which extends an abstract class must implement all the abstract methods. Otherwise, they should be made abstract as well.

  • @parijatbandyopadhyay8057
    @parijatbandyopadhyay8057 2 ปีที่แล้ว

    Man you are awesome :) super clear explanation. Thanks

  • @Rachel-hi3yv
    @Rachel-hi3yv 4 ปีที่แล้ว

    Thank you so much Alex!! You are a fantastic teacher.

  • @kwsrchoudhury
    @kwsrchoudhury 3 ปีที่แล้ว

    I was looking for a simple example and explanation on this and it helped so much! thanks!

  • @hamidarenabdi9611
    @hamidarenabdi9611 4 ปีที่แล้ว

    I appreciate you.
    Your videos are great, simple and useful.

  • @Vishalpawar_96
    @Vishalpawar_96 4 ปีที่แล้ว

    You have insightly explained Alex....I got it understood very well...nice try.

  • @darthpongo5457
    @darthpongo5457 2 ปีที่แล้ว

    Wow thank you man this is so easy to follow

  • @Lucas-qc3yf
    @Lucas-qc3yf 5 ปีที่แล้ว +1

    Hey, how i can set a Char color without JFrame, buttons, etc... only in eclipse console? For example: I have a Char 'Z' of zombie and i have to set this char to green on console, how i can do this? Thanks

  • @allisoncrenshaw3799
    @allisoncrenshaw3799 4 ปีที่แล้ว +1

    Do you have any videos that cover lambdas? I haven't seen any but could be missing it

  • @ilejovcevski79
    @ilejovcevski79 4 ปีที่แล้ว

    Please make a video about the use of interfaces when solving the inheritance problem in java. I think it's what they are used for the most.

  • @g194g
    @g194g 4 ปีที่แล้ว

    Grateful for this vid!

  • @muhammadhassan6364
    @muhammadhassan6364 2 ปีที่แล้ว

    bruh light mode !! nice tutorial 💖💖

  • @valsant4
    @valsant4 5 ปีที่แล้ว +1

    so helpful, thank you Alex ! :)

  • @DiaborMagics
    @DiaborMagics 3 หลายเดือนก่อน

    And when would you use an interface and when would you use a superclass instead?

  • @jingzhao8912
    @jingzhao8912 4 ปีที่แล้ว

    Thank you very much. you make everything easier ...

  • @gaigerharr6980
    @gaigerharr6980 4 ปีที่แล้ว

    it took me 3:49 minute to understand interface thank you.

  • @maheshgudisa7754
    @maheshgudisa7754 11 วันที่ผ่านมา

    What was best compiler for java programming

  • @pendago8484
    @pendago8484 2 ปีที่แล้ว

    Did I say thanx for your vids? So helpfull!

  • @eleynar.7249
    @eleynar.7249 3 ปีที่แล้ว

    Wow thank you!!! You explained it so well 🥰🥰

  • @AMANMUJAWAR-sq6qv
    @AMANMUJAWAR-sq6qv 2 ปีที่แล้ว

    Thank_u_Brother you made my concept easy keep growing😀😀😀😀😀😀

  • @gingertrilogy366
    @gingertrilogy366 4 ปีที่แล้ว

    Great Video Alex!

  • @lilv728
    @lilv728 ปีที่แล้ว

    This was very helpful. I practiced along side with you and l got a lot out of it. I will say though technically can't you avoid forcing the class implementing the interface to use every method in the interface by setting the access modifier of any methods not required as default?

  • @yaboialiisg
    @yaboialiisg 3 ปีที่แล้ว

    super helpful Alex, thank you a ton!

  • @tanishpanjwani3117
    @tanishpanjwani3117 2 ปีที่แล้ว

    Thank you very much. It was extremely helpful.

  • @K.E.N.J.I.B.A.B.Y
    @K.E.N.J.I.B.A.B.Y 3 ปีที่แล้ว

    Great job explaining that!

  • @faiza.s6509
    @faiza.s6509 3 ปีที่แล้ว

    Cheers! Thanks for your amazing videos!

  • @zinx6809
    @zinx6809 3 ปีที่แล้ว

    Thanks. Was at it for over 2 hours cuz had to use interface in the project. Now you made it easy now I feel stupid .

  • @benitaezeoke1568
    @benitaezeoke1568 ปีที่แล้ว

    why did you stop creating java content !!!! been looking for you. i need your video on MAP, ARRAYLIST,LINKEDLIST,HASHSET, your videos have been life saver for me

  • @aquilhall262
    @aquilhall262 4 ปีที่แล้ว +3

    Can you do a tutorial on marker interfaces? I've never encountered anything so abstract!

    • @الإسلامدينالحق-خ5ت
      @الإسلامدينالحق-خ5ت 2 ปีที่แล้ว

      as a beginning to know the purpose of your existence in this life.👇 .My friends, search for your life purpose, why are we here?? I advise you to watch this series th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html

  • @Amranwen
    @Amranwen 4 ปีที่แล้ว

    Thank you so much for all your videos! You really help me with learning :D

  • @yololifestyle4541
    @yololifestyle4541 4 ปีที่แล้ว

    Me: *clicks first tutorial from searches*
    TH-camr: "Hey, Im Alex, please subscribe"
    Me: "woah woah we just met bro"

  • @varadaraajjv4973
    @varadaraajjv4973 4 ปีที่แล้ว

    Your videos are nice...excellent...thanks for the help

  • @chuliza
    @chuliza 3 ปีที่แล้ว

    Bro.... that opening statement... hahahahaha completely killed me

  • @Eurotool
    @Eurotool 4 ปีที่แล้ว +1

    Huh why are 360p and 1080p available but not 720p

  • @joshualippss
    @joshualippss 4 ปีที่แล้ว

    I know how to do it now, but i dont know for what...great!

  • @firdausnaz2349
    @firdausnaz2349 4 ปีที่แล้ว +1

    Thank you Alex. It was a helpful content. But, if i have two interfaces, how will i write both the interfaces in the same class?

    • @ariton2990
      @ariton2990 4 ปีที่แล้ว +1

      implements interface1, interface2, interface3 ......