Tuesday, 15 September 2015

java - Freeze an Integer -



java - Freeze an Integer -

i'm working on app uses lot's of imagebuttons , on every ontouch event on imagebuttons value added integer variable. here comes problem, let's have statement returns true @ point:

if (x == y)

how can create integervariable remain same if user touches 1 time again images? illustration this:

if (x == y){ integervariable not change};

you command via custom boolean. it's reasons (custom, non standard field access) getters , setters suggested.

only ever utilize setter setmyint(int value) in code , never access field straight , ok. if need know whether value updated, @ returned boolean.

private int myint; private boolean ismyintlocked = false; public boolean setmyint(int value) { if (ismyintlocked) { log.i(tag, "cannot set myint, it's been locked"); homecoming false; } else { this.myint = value; homecoming true; } } public void lockmyint(boolean dolock) { this.ismyintlocked = dolock; }

java if-statement integer

No comments:

Post a Comment