Variables come in two flavors
primitive
as object state(instance variables)
reference
as local variables( variables decleard within a method )
Type
Bit Depth
Value Range
boolean
JVM-specific
true of false
char
16 bits
0 to 65535
byte
8 bits
-128 to 127
short
-32768 to 32767
int
32 bits
-2147483648 to 2147483647
long
64 bits
-huge to huge
float
varies
double
There is actually no such thing as an object variable.
There's only an object reference variable.
An object reference variable holds bits that represent a way to access an object.
It doesn't hold the object itself,but it holds something like a pointer.Or an address.
You can't stuff an object into a variable.Objcet live in one place and one place only -- the garbage collectible heap!
When obeject is not assigned,it is abandoned and eligible for Garbage Collection(GC).
变量有两种类型
基本类型
作为对象里的声明(实例变量)
引用类型
作为局部变量(变量声明在方法内)
类型
位深
取值范围
-很多到+很多
变化的
控制你的对象
实际上没有对象变量
仅仅只是对象引用变量
对象引用变量是二进制数,代表进入对象的方法
对象引用变量不是对象,但它像指针或者地址。
当对象没有被变量指定,它将会被丢弃,并符合垃圾收集(GC)的条件。
Last updated 7 years ago