Head First Java

->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).

->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值