??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
2?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> Java 中所有的对象都是通过 new 来动态?/span>
3?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 所有的容器 (collection) ?/span> Object array( 对象数组 e.g String []str=new String[10]) 内都包含都是对象?/span> reference
4?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
?/span>
java
中,
java
~译器有责Q产生“将
stack
指针前后Ud“的E序代码Q所?/span>
它必能够完全掌握它所~译的的E序中“存?/span>
stack
里头的所有数据的实际大小和存zL间“,
如此一来便会限制程序的Ҏ?/span>
׃q个限制Q尽我们可以将对象?/span>
reference
存储?/span>
stack
内,但却不能一般的
java
对象攑֜
stack
?/span>
特例Q(
primitive
types
Q?/span>
基本型别会经常被使用Q如果?/span>
new
来生此cL,极简单的变量Q会因?/span>
new
对象置?/span>
heap
之上?/span>
而效率不好。因此对于此cd?/span>
java
采取
c/c++
的方式,也就是不?/span>
new
分配器空_而是产生一U所谓的
”automatic
“变量,存于
static
?/span>
5?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 当你产生某个存储对象的数l,真正产生的是个存?/span> reference 的数l。此数组建立之后Q其中的每一?/span> reference 都会被自动设为某个特D的?/span> null,
6?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> { String s=new String(“ddd?;} s q个 reference 会在生存I间之外消失无踪Q但是, s 先前所指的那个 String 对象仍然会l占用内?/span>
7?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> Class 内的基本型别变量都有初|但是在函数内?/span> local variable 是没有初值的
8?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> Java 中,所有传递的对象的场合,传递的都是对象?/span> reference.
9?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> Return Q?/span> 说明q个函数q行l束Q返回到其调用函数?/span> Return 2 Q返回一个数 2 l调用者,同时l束本函数的q行?/span>
10?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> Class 内的 non-static data(state) ?/span> method , 都是和特定的对象l定的,一般情况下Q你的生某个对象,再通过该对象取用其数据和函数。所?/span> non-static 数据 / 函数必须知道他们隶属于哪一个对象,才有办法q行 .static 函数内不能?/span> non-static 数据和函?/span>
11?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
(object1= = object2 )
两个对象?/span>
reference
?/span>
= =
比较得是两个对象的内存的地址。所以我们不能?/span>
= =
来测试两个对象的内容是否相等。如果想试对象的内Ҏ否相{,应该使用
equal(),
M一个对象都拥有q个函数。不q你自己?/span>
class
需?/span>
override
q个函数Q否则默认的
equal()
函数是还是比较的两个对象的内存地址?/span>
Java
标准E序库中的大多数
class
?/span>
override
?/span>
equal(),
所以他们都会比较对象的内容是否相等?/span>
12?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 位运符都是作用于基本正数类型。该q算W主要是针对g~程使用Q我们用得不多,Q?/span>
待箋