我正在读一本书"Thinking in Java",它说对象存储在堆上,静态变量存储在一些固定的位置,比如静态存储,这样它们就可以在整个时间程序中运行.
class Myclass{
static int x =0; //stored on static storage
Myclass obj = new Myclass(); //stored on heap
}
Run Code Online (Sandbox Code Playgroud)
虽然制作一个对象,但就OOPS而言,静态不是一个好主意.把它搁置一段时间.有我的问题
class Myclass { static Myclass obj = new Myclass(); //no man's land }| 归档时间: |
|
| 查看次数: |
2126 次 |
| 最近记录: |