difference between 'static int' and 'i

2020-07-27 02:55发布

in java where and when do we use 'static int' and how does it differ from 'int'

标签: java
7条回答
做自己的国王
2楼-- · 2020-07-27 03:56

Take a look here: Understanding Instance and Class Members

When a number of objects are created from the same class blueprint, they each have their own distinct copies of instance variables. (...)

Sometimes, you want to have variables that are common to all objects. This is accomplished with the static modifier. Fields that have the static modifier in their declaration are called static fields or class variables.

查看更多
登录 后发表回答