java - Make-shift string boolean? -


i attempting create sort of settings system project creating, have hit of problem. i'm trying use string (considering these settings must later saved text file) make-shift boolean. so, need able switch string between true , false. assumed following method work, reason sets true regardless. is, far know, place in code variable set.

i have no idea why following code shouldn't work, , i've done thorough searching no avail.

if("true".equals(settings[0]))     settings[0] = "false";             //this *always* skipped else if("false".equals(settings[0]))     settings[0] = "true";` 

therefore, i've come here.

convert string bool , inverse result. sample

string[] settings = {"true"}; boolean settingbool = !boolean.parseboolean(settings[0]); system.out.println(settingbool); 

output:

false 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -