#37 Static Variable in Java

Поділитися
Вставка
  • Опубліковано 1 лют 2025

КОМЕНТАРІ • 26

  • @MdRahaman-pj9rc
    @MdRahaman-pj9rc Рік тому +20

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

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

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

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

    thanks dear theacer your Student from Afghanistan

  • @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?

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

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

  • @harithlukman3550
    @harithlukman3550 2 місяці тому

    Great explanation!

  • @ahmadwaheed8003
    @ahmadwaheed8003 Рік тому +3

    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?

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

    Well explained 🎉❤

  • @gedelasivakrishna
    @gedelasivakrishna 21 день тому

    Thankyou !

  • @MoeMoe-qr7od
    @MoeMoe-qr7od Рік тому

    excellent explain static

  • @MahadevBhakt-v2l
    @MahadevBhakt-v2l Рік тому +1

    nice explanation sir

  • @codingkrtehum..
    @codingkrtehum.. 15 днів тому

    My doubt here,
    name was still of type String and as not defined so by default it's immutable.
    How is name being mutable then?
    Please clear this doubt.

  • @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.

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

    Well explanation

  • @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...

  • @nitinanand3408
    @nitinanand3408 Рік тому +26

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

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

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

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

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

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

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