#37 Static Variable in Java

Поделиться
HTML-код
  • Опубликовано: 11 янв 2025

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

  • @MdRahaman-pj9rc
    @MdRahaman-pj9rc Год назад +20

    Your explanation of static variable helps to understand static keywords better. Thanks.

  • @apoorvsingh660
    @apoorvsingh660 4 месяца назад +5

    still can't believe you're providing this level of content free..

  • @ajayghode3602
    @ajayghode3602 25 дней назад

    Thank You ..After a long time I got to know the real reason for creating the show method

  • @sarthaknema1130
    @sarthaknema1130 Год назад +7

    Can I say a static variable is like a global variable? So local variables can only be shared/used among the instance/object. But a global variable can be used by the entire class and every instance/object belonging to that class?

  • @zobaidullahniazmand4375
    @zobaidullahniazmand4375 Год назад +4

    thanks dear theacer your Student from Afghanistan

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

    Great explanation!

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

    Very helpful !
    When creating the variable static name, you said that the name property of obj1 and obj2 will share the same static name, the static name is stored in an area in the heap memory, then the name attribute of obj1 and the name attribute of obj2 are in memory heap will contain the address of the static name in the heap memory right?

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

    Great explanation

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

    But when we access static variable with object ref then we can change the value of static variable for all the objects then how its maintain rule of common for all (Belong to class ) or its just behaves like instance variable with hard core value ???? Is Memory saving the only difference ???

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

      Yes we can access with object reference but it will reflect in all the objects so it is called common area.

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

      Yes when we make a common variable for all the objects we don't need to initialize it with each object so memory saving is the advantage of using static.

  • @MahadevBhakt-v2l
    @MahadevBhakt-v2l Год назад +1

    nice explanation sir

  • @spiderman699
    @spiderman699 11 месяцев назад

    Well explained 🎉❤

  • @MoeMoe-qr7od
    @MoeMoe-qr7od 11 месяцев назад

    excellent explain static

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

    Sir I had an interview yesterday what is the significance of static variable .I don't know can you explain

    • @alinakhan1159
      @alinakhan1159 11 месяцев назад +3

      less memory is used for instance if you declare 3 non static integer variables then each object will occupy 12 bytes of memory ..if there are 3 objects total will be 36 but if you declare one static variable and if the other 2 are non static then static variable will take its 4 bytes which will be shared with all objects and each object will separately take its 8 bytes of storage..so total memory that is used for 3 objects will be 24 bytes and 24+4 is 28 bytes...

  • @gedelasivakrishna
    @gedelasivakrishna День назад

    Thankyou !

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

    Well explanation

  • @nitinanand3408
    @nitinanand3408 Год назад +26

    By the way price of an apple is lower than price of samsung... Must throw an error

  • @ajayghode3602
    @ajayghode3602 25 дней назад

    New learning "static variables should be called with there class name".

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

    Sir where the static variable is stored ?? Inside stack memory or Heap memory ?

  • @puruagni1927
    @puruagni1927 8 месяцев назад

    Why are you not updating VS Code? Please update VS Code.