1 回答

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超21個(gè)贊
long lastClick放在 函數(shù)外, 是對(duì)象的成員變量, 默認(rèn)初始化為0.
放在函數(shù)內(nèi), 稱為本地變量. JLS7, #16 里有寫(xiě):
"EACH local variable (§14.4) and every blank final field (§4.12.4,
§8.3.1.2) must have a definitely assigned value when any access of its
value occurs. An access to its value consists of the simple name of
the variable (or, for a field, the simple name of the field qualified
by this) occurring anywhere in an expression except as the left-hand
operand of the simple assignment operator = (§15.26.1). For every
access of a local variable or blank final field x, x must be
definitely assigned before the access, or a compile-time error occurs"
添加回答
舉報(bào)