java - If Statement String = Text for displaying different things on country -


maybe stupid question want use if statement in code, won't work.

 string country = getresources().getconfiguration().locale.getlanguage(); if (country = nl); 

so want use if statement function when country string "nl" don't know how use if statement think.

it's

if (country.equals("nl")) ... 

now:

  1. equality in general tested double ==.
  2. string equality should tested equals.

some more info future use: using == test equality checks if references same (i.e. same object in memory), not need (of course, using primitive values works expected). cases when want have custom equality checks on types can override equals method , place logic there. happens in case of string class.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -