#62 Inner Class in Java

Поділитися
Вставка
  • Опубліковано 23 січ 2025
  • Check out our courses:
    Java Full Stack and Spring AI - go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    DevOps with AWS: From Basics to Mastery : 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
    website : courses.telusk...
    In this lecture we will learn:
    What is an inner class in Java?
    Static inner classes in Java
    Advantages Of inner class
    #1
    Inner Class:-
    We can also create a class inside another class.
    class A
    {
    class B
    {
    }
    }
    You can call the method of class B by using the dot operator in between both classes A and B.
    A.B obj= new B();
    A dollar sign will be introduced in a class name that has an inner class indicating two different classes.
    A$B. class
    You also need to create an object of the outer class, to call the methods of an inner class.
    #2
    Static Inner Class:-
    An inner class can also be declared as static.
    When an inner class is declared as static, then you do not need to create an object for it.
    But an outer class can not be made static.
    #3
    Advantage of inner class:-
    Nested classes represent a particular type of relationship that is it can access all the members of the outer class, including private.
    Nested classes make the code more readable and maintainable.
    It makes the code more optimize.
    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

  • @Harshithkatukam
    @Harshithkatukam 3 місяці тому +7

    inner class in java are of four different types:
    Non - Static inner class
    Static inner class - It can access only static members of outer class
    Anonymous inner class - inner class without any name , it is used to create only one object of inner class
    Local inner class - inner class defined in method or block within inner class ( it can only access local variables of the method in which it is defined and local variables must be effectively final)

  • @seeesh1165
    @seeesh1165 Рік тому +21

    Bro is the best teacher in the world !

  • @raghavsood768
    @raghavsood768 Рік тому +35

    Only inner class can be static

  • @priyanshu6339
    @priyanshu6339 Рік тому +5

    Good explaination

  • @sheikhraisulislam4483
    @sheikhraisulislam4483 Рік тому +4

    really good

  • @reddykailasam1617
    @reddykailasam1617 8 місяців тому +5

    Sir, please can u do videos in telugu?
    Your explanation is wonderful. If u do videos in telugu, a lot of telugu people will understand and learn Java

  • @nardosabraham-w9v
    @nardosabraham-w9v 8 місяців тому +1

    Thanks

  • @JustwaitNwatch-w
    @JustwaitNwatch-w Рік тому

    Thanks

  • @toptecher1633
    @toptecher1633 9 місяців тому

    sir when i am doing so i am getting error obj package not found
    A obj = new A();
    A.B = new obj.B();
    //i have made class A and B as you made
    //when i make B static it works well

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

      To instantiate an inner class, you need to first create an instance of the outer class, then use that instance to create the inner class object.
      A obj = new A();
      A.B obj1 = obj.new B();

  • @talhaofficial87
    @talhaofficial87 8 місяців тому

    but sir ham to static ka object banaty hi nahi hy to ye kese ho raha hy

  • @harshabannaravuri9229
    @harshabannaravuri9229 Рік тому +1

    Why outer class cannot be private are protected

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

    Are all inner class static and vice versa

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

    " Why" the concept of Inner class?
    Can someone please explain

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

    I don't understand why you need innerclass