Java - static Keyword

static In simple words: static means the variable or methods that assigned to are belonging to the class, not the object. Therefore, there’s only one copy of the variable/method in the memory. When create an object where all instance variables aren’t static, every object will own its memory space, and its own copy of value. Suppose we have a ball class: class Ball{ double radius; final double PI = 3.14159; } We create 2 Ball objects, each Ball object will have its own instance variables in the memory...

April 18, 2022 · 5 min · Derry