Head First Java chapter3 (primitives and variables)

首先是每一章里面书中自带总结。
  •  Variables come in two flavors: primitive and 
    reference.
  • Variables must always be declared with a name 
    and a type. 
  • A primitive variable value is the bits representing 
    the value (5, ‘a’, true, 3.1416, etc.).
  • A reference variable value is the bits 
    representing a way to get to an object on the 
    heap.
  • A reference variable is like a remote control. 
    Using the dot operator (.) on a reference 
    variable is like pressing a button on the remote 
    control to access a method or instance variable.
  • A reference variable has a value of null when 
    it is not referencing any object.
  • An array is always an object, even if the array is declared
     to hold primitives. There is no such thing as a primitive array,
     only an array that holds primitives.
下面是一些 我认为有必要的摘抄:

rules of name(class, method or variable):
  • It must start with a letter, underscore (_), or dollar sign ($).
     You can’t start a name with a number.
  • After the fi rst character, you can use numbers as 
    well. Just don’t start it with a number.
  • It can be anything you like, subject to those two
    rules, just so long as it isn’t one of Java’s reserved words.

3 steps of object declaration, creation, and assignment:

                        Dog myDog = new Dog();

  1. declare a reference variable(等号左边)
  2. create an object(等号右边)
  3. link the object and the reference(等号的作用)

一张图理解Java的数组:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值