java - What is difference between Fields and Constants in android documentations? -


what difference between fields , constants in android documentations? example in view class have fields , constants.whiles, think constants in view class fields. because each variable in each class field. please example me ambiguity.

when app compiled, constant values compiled directly application. using example @commonsware's comment, accessibility_live_region_assertive integer value 2. value continue used app if view class updated in future release of android, why can't put "what version of android running on" in constant. conversely, it's fine way record version of sdk app compiled against.

the fields final, means can't change them, unless use jni, in case can. however, because compiler uses values directly whenever possible, changing value of final fields won't affect code -- unless accesses them through reflection.

so distinction between "constant" , "field" may of importance.

primitive types , strings may constants. arrays , other object types, such int[] used selected_state_set, reference read-only, contents of object not. true of mutable object type, doesn't make sense list them under "constants".


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -