Inner Class Java Tutorial #81

Поділитися
Вставка
  • Опубліковано 9 чер 2024
  • $1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
    An inner class in Java, is a class inside of a class, like this:
    class ClassOne {
    class ClassTwo {
    }
    }
    A class just has variables and methods. But you can also put another class inside and make an inner class (i.e nested class) for readability and maintainability.
    I hope you enjoyed this inner classes tutorial!
    Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
    Free Tips: bit.ly/3U6HXcb
    Disclosure: Springboard link provided is linked to my affiliate account & supports the channel.
    Alex Lee

КОМЕНТАРІ • 86

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

    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

  • @harnoorsingh3962
    @harnoorsingh3962 3 роки тому +63

    The best Java UA-camr out there

  • @spicynoodles3317
    @spicynoodles3317 3 роки тому +15

    Hi Alex! I'm prepping for my Java certification as a high school student and have been slowly burning through all your videos this summer. I can't thank you enough for all the free, high quality tutorials you've given all of us and hope you know that what you're doing is really helping us kiddos get into computer science.

    • @krishshah3974
      @krishshah3974 2 роки тому +2

      how'd it go :)

    • @itsblu4735
      @itsblu4735 26 днів тому

      I'm in uni n understanding from him too like

  • @celephaisx4939
    @celephaisx4939 Рік тому +2

    I've binge-watched all your videos on java basics and intermediate java and I practiced at the same time and I must say it's the first time I have all these cleared up inside my head. Thank you for everything you did for us! You saved a lot of us :)

  • @jessadelacruz2079
    @jessadelacruz2079 3 роки тому +3

    I really admire how you can make Java easy to understand and not getting complicated. Thank you!!

  • @ProfessorSauvaje
    @ProfessorSauvaje 3 роки тому +7

    short and to the point
    thank you

  • @manueloaustria2124
    @manueloaustria2124 Місяць тому

    This is great, really helpful to understand what is inner class. Thanks for sharing this

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

    hey alex just completed your intermediate coarse ....thanks a lot ,u are doing a wonderful job and good karma at appx. our age
    keep up the work and stay blessed

  • @lakshminarayanamaddi6970
    @lakshminarayanamaddi6970 7 місяців тому

    Thanks Alex..you are making Java simple to learn from me..

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

    Literally say, "Yes let's go baby!" when I search for a java concept and this guy's made a video on it

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

    U are the best java teacher in the world

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

    Great example and straight explanation bro! Weird, but interesting. Now I'm wondering where to take advantage of it. 🤔

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

    finally my biggest question regarding java clearing today , i even felt problem in Android with inner classes like when we create adapters,,their are lots of inner classes in it,, ,Thanks mate love from Pakistan

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

    thank you so much for these videos

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

    good description and examples :)

  • @mannyokafor4609
    @mannyokafor4609 3 роки тому +16

    Imagine the project name, but outta context.

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

    HIIII! Your vids help me soo much

  • @mohamedkanu66
    @mohamedkanu66 3 роки тому +3

    Learning your videos have been fun kind of and truly engaging . Would you please organise the Java tutorials into a numbered playlist ? This will help us follow u sequentially! Thank u 🙏🏾

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

    You are really good!

  • @faiza.s6509
    @faiza.s6509 3 роки тому

    Thank you!

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

    good video, good explanation.

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

    If you haven’t already, can you make a video on Overriding methods during inheritance?

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

    Dude said “I know this looks comfusing”...after i wasted so many hours of my life trying to figure out my Java trainer’s stupid example with icecream trucks.🤦🏻‍♂️Man you make it so easy to understand...

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

    Thank you :)

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

    all makes sense now

  • @r.m.a.j7770
    @r.m.a.j7770 3 роки тому +2

    Loved it✌🏻

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

      U haven't even watched it bruh the video is 4 mins long and u commented this after a minute of it being released

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

      @@zeradris Yes 😂

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

    thank you

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

    Hi Alex, would you happen to have tutorial about Java wildcard?

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

    I love you lee

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

    Can you make a video about Optional Class?

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

    Can you give me an example when this class inside a class needed in a program.

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

    Good Explanation. Please add this to your next video ===> Types of Inner Class:- i) Normal Class or Regular Inner Class
    ii) Method Local Inner Class iii) Anonymous Inner Class iv) Static Inner Class

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

    Can you teach how to create temporary objects in java

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

    Brother Can you please make a video on wrapping a java project to exe file.

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

    I have commented on ur tictactoe video about "cannot find c" from containsAll()..i use bluej and it doesn't have that feature to import ' bad boy' like that

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

    the link for your course isnt working for me, is it geolocked?

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

    can it be declared as
    Object i = new Outside().new Inside();

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

    Would it make sense to structure your code using Inner Class if it extends Outer Class? For example, if the outer class is vehicle; then you add inner classes for car, van, and motorcycle? Thanks for running the best Java vids I've found!

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

      I think it’s not exactly the case but, for instance, you can have the Car class with the inner class Engine. Engine is a complex structure which has it’s properties and functionality and every car has it. Hope it makes sense

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

    I thought nested classes were an alternative to using "extends" on your subclasses. I guess that's not really the case. Thank you for clearing my mind.

  • @JoonPark1
    @JoonPark1 2 роки тому +1

    3:50 That's not true. Static inner classes have access to the fields of the wrapping class but the reason it's not able to access it is because int a is an instance variable.

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

    Can you make a video on object casting (upcasting) please! Thanks for the great content. ☕☕☕

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

    yas

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

    can u make a video about windowBuilder i cant install it on eclipse

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

      bro u can use netbeans

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

    Could you work for SpaceX?

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

    Thanks that was really helpful! Why do inner classes exist at all though? Couldn't you program everything computable without them? Is it to help you achieve the single responsibility principle?

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

    Alex can you please make a video explaining the difference between next() vs nextLine() ? PLEASE!

    • @Nino-xe3oj
      @Nino-xe3oj Рік тому

      In Java, both next() and nextLine() are methods of the Scanner class that are used to read user input from the console.
      next() method reads the next token (sequence of characters separated by whitespace) and returns it as a string. It stops reading when it encounters whitespace (space, tab, or newline). For example, if the user enters "Hello World", next() will only return "Hello".
      On the other hand, nextLine() reads the entire line of input entered by the user, including any spaces or tabs. It stops reading only when it encounters a newline character, which is created when the user presses the Enter key. For example, if the user enters "Hello World", nextLine() will return the entire string "Hello World". Hope this clears it up!

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

      @@Nino-xe3oj Thank you bro.

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

    Do tutorials on stuff like algs and data structures too!. im sure many people will like it too.

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

    if you were to do it the way shown at 3:26 how would you print a?

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

      You would first have to instantiate another object from the Outside class, as opposed to instantiating it from the Inside class. I'm not certain but I believe there's another (simpler) way to do it as well.

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

    Bro how many programming languages do you know and are you a full stack developer?? Please reply me. I will be grateful if you reply me😀😀

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

    I know this is an old video but hopefully you still read comments I was just wondering I tried in my IDE and I was able to do
    Outside o = new Outside();
    Inside = o.new Inside();
    Is it any different from doing it like you at 1:43?

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

      Hi Paskalo. Are you sure? Because my IDE wasn't able to recognize Inside

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

      @@JoonPark1 I mistyped it, if you look closely I didn't assign a variable name to the type Inside but if you do then it works.
      Inside o = o.new Inside();

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

    JavaFX tutorial?? pls

  • @DaNa-px7ol
    @DaNa-px7ol 3 роки тому

    could you please teach Java at my university? you´d save many lives

  • @shahad1679
    @shahad1679 3 місяці тому

    We need composition plz 😢

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

    Bro i really appreciate your effort but that background musics are distracting plz use instrumental music as a background

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

    Can you tell me the difference between importing and extending a class in java

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

      I believe talks about extending classes in this video:
      ua-cam.com/video/zbVAU7lK25Q/v-deo.html

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

      Import is a keyword that imports a class from different package, so the class you are working in can directly access it`s name. For example Scanner class is located in java.util, and if you wanted to create a Scanner object, you would have to do it like this:
      java.util.Scanner scanner = new java.util.Scanner();
      But if you import it with: import java.util.Scanner, you can create a Scanner object like this:
      Scanner scanner = new Scanner()
      extend is part of the inheritance. When a class extends another class, it inherits all of its methods and variables.

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

      My main question is when to use extends to inherit a class and then using it and when to use the class directly by making its object.

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

      @@kumat7 You would use inheritance when it makes sense for multiple classes to share the same code. So instead of copy&pasting the code in each class, you would have 1 base parent class that has the code the classes would share, and then the classes would extend it. Inheritance means IS-A relationship. Example: Dog IS-A animal, so it makes sense for dog to extend Animal. Knife IS-A Weapon, so it would make sense for Knife to extend Weapon. For example imagine you are doing a simple game with animals and you would want to code animals. What does every animal share in the game? Every animal would have position, speed, health, strength, defense... methods: attack(), move(), die()......
      Code example:
      public class Animal {
      private int x, y; // coordinates for position
      private int speed;
      private int health;
      private int strength;
      private int defense;
      public Animal() { } // constructor
      public void attack() {
      // code for attack
      }
      public void move() {
      // code for movement
      }
      public void die() {
      // code that checks if health is zero and then deletes the animal if it is
      }
      }
      Then you would have for example Dog class that extends Animal class:
      public class Dog extends Animal {
      // some extra attributes and methods that only dog has
      }
      So now the Dog class has all the attributes and methods of Animal and also some own attributes and methods. You could then also do other animals like Cat.
      Hope this makes it clear.

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

      @@ariton2990 Thanks for clearing my doubts

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

    I had a eh? Moment then I realised that the innerclass was static 😅 I think an example of the outer scope world of been nice

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

      oh my god that is so freaking true

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

    do anonymous classes next

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

    it really sucks to live in a third world country . not trying to bitch about it or anything but it got to me ...
    one of the simple things i want is this java course but guess what i cant afford it . lol its funny to think that the price is one of my parents salary .
    the f ing corrupted countries we live in ey .
    and thanks Alex for the valuable free content ...
    if you reading this and you are fortunate enough please acknowledge that .
    hope you all a nice day.

  • @itsblu4735
    @itsblu4735 26 днів тому

    My least fav chapt tbh hope it doesn't come on the exam 🧍🏻‍♀️

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

    i dont know what you will think but i wanna say that you are very cute.😶😶...

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

    Thank you!