android如何提升性能技巧(上)
Map myMap1 = new HashMap();
HashMap myMap2 = new HashMap();
for (int i = 0; i< this.mCount; i++)
dumpItem(this.mItems[i]);
最好改成這樣:
int count = this.mCount;
Item[] items = this.mItems;
for (int i = 0; i< count; i++) dumpItems(items[i]);
static int intVal = 42;
static String strVal = “Hello, world!”;
static final int intVal = 42;
static final String strVal = “Hello, world!”;
public class Foo {
private int mValue;
public void run() {
Inner in = new Inner();
mValue = 27;
in.stuff();
}
private class Inner {
void stuff() {
System.out.println(Foo.this.mValue);
}
}
}
Foo$Inner是一個完全獨立的類,它要直接訪問Foo的私有成員是非法的。編譯器會自動生成一個方法:
static int Foo.access$100(Foo foo) {
return foo.mValue;
}
Android API
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。