->In Java, programmers care about two areas of memory---the one where objects live(the heap), and the one where method invocations and local variables live(the stack). All objects live on the garbage-collectible heap. Where a variable lives depends on what kind of variable it is. And by "kind", we don't mean type(i.e. primitive or object reference). The two kinds of variables whose lives we care about now are instance variables and local variables. Instance variables are declared inside a class but not inside a method. Local variables are declared inside a method, including method parameters.
->The thing that separates a method from a constructor is the return type. Methods must have a return type, but constructors cannot have a return type.
->Constructors are not inherited.
->Instance variables are assigned a default value, even when you don't explicitly assign one. The default values are 0/0.0/false for primitives, and null for references.
->An object becomes eligible for GC when its last live reference disappears.Three ways to get rid of an object's reference:
1.The reference goes out of scope, permanently
void go() {
Life z = new Life();
}
2.The reference is assigned another object
Life z = new Life();
z = new Life();
3.The reference is explicitly set to null
Life z = new Life();
z = null;
->When you want to sort the same thing in more than one way, you can use another sort() method---and it takes a Comparator: sort(List<T>list,Comparator<? super T >C).
->
->The thing that separates a method from a constructor is the return type. Methods must have a return type, but constructors cannot have a return type.
->Constructors are not inherited.
->Instance variables are assigned a default value, even when you don't explicitly assign one. The default values are 0/0.0/false for primitives, and null for references.
->An object becomes eligible for GC when its last live reference disappears.Three ways to get rid of an object's reference:
1.The reference goes out of scope, permanently
void go() {
Life z = new Life();
}
2.The reference is assigned another object
Life z = new Life();
z = new Life();
3.The reference is explicitly set to null
Life z = new Life();
z = null;
->When you want to sort the same thing in more than one way, you can use another sort() method---and it takes a Comparator: sort(List<T>list,Comparator<? super T >C).
->