際際滷

際際滷Share a Scribd company logo
Effective Java for
Mobile
亳亳仍仍 仂亰仂于
亞舒仆亳亠仆亳 仄仂弍亳仍仆
仂亶于
 仂亠仂
 RAM
 舒仄
 舒舒亠亶从舒
 亠舒弍亳仍仆亶 亳亞仆舒仍
仗仂仍亰亶亠 仂仍仂亢亠仆仆仂亠 (lazy)
仗仂仍亠仆亳亠 仍仂亢仆 亟舒仆仆,
仂仍从仂 于 仂 仄仂仄亠仆 从仂亞亟舒 仂仆亳
于舒仄 仗仂仆舒亟仂弍
仗仂仍亰亶亠 从 亟仍
亠亰仍舒仂于 仍仂亢仆 于亳仍亠仆亳亶
从仂仂亠 仗仂仆舒亟仂弍 于舒仄
仆亠从仂仍从仂 舒亰
亰弍亠亞舒亶亠 仂亰亟舒仆亳亠
仆亠仆亢仆 仂弍亠从仂于
亠 亳仗仂仍亰仂于舒 仄舒亳于
亟舒仆仆 仗亳仄亳亳于仆仂亞仂 亳仗舒,
亠仄 仄舒亳于 亳仗仂于-仂弍亠仂从
亠 亳仗仂仍亰亶亠
static 于仄亠仂 virtual
亰弍亠亞舒亶亠
亳仗仂仍亰仂于舒仆亳亠 Getter-仂于/
Setter-仂于 于仆亳 从仍舒仂于
亠亰 JIT 亟仂仗 从 仗仂仍礆 仆舒仗礆 于 3
舒亰舒 弍亠亠

弌 JIT - 于 7 舒亰
public class Foo {
private class Inner {
void stuff() { Foo.this.doStuff(Foo.this.mValue); }
}

private int mValue;

public void run() {
Inner in = new Inner();
mValue = 27;
in.stuff();
}

private void doStuff(int value) {
System.out.println("Value is " + value);
}
}
仗仂仍亰亶亠
仄仂亟亳亳从舒仂 亟仂仗舒 仗仂
仄仂仍舒仆亳 于仄亠仂
private 于 仍舒亠 从仂亞亟舒
仗仂亳仂亟亳 仂弍舒亠仆亳 从
仍亠仄亠仆舒仄 亳亰
于仆亠仆仆亳 从仍舒仂于
List<String> strings =
Arrays.asList("one", "two", "three");

// Indexed for
for (int i = 0; i < strings.size(); i++) {
System.out.println(strings.get(i));
}

// Optimized indexed for
for (int i = 0, count = strings.size(); i < count; i++) {
System.out.println(strings.get(i));
}

//Iterator
for (String item : strings) { System.out.println(item); }

//Collection Stream API
strings.forEach(System.out::println);
弌舒舒亶亠 仆亠
亳仗仂仍亰仂于舒
亠仍亠从亳
亠 仂亰亟舒于舒亶亠 仂弍亠从
于 亳仆亠仆亳于仆仂
于亰于舒亠仄仂仄 从仂亟亠
弌舒舒亶亠 仂仍仂亢亳 亰舒亟舒亳
从仂亞亟舒 仂亶于仂 弍亟亠 亳仄亠
弍仂仍亠 亠仂于 于 于仂亠仄
舒仗仂礀亠仆亳亠

More Related Content

Effective Java