nanohttpd - The string contain "/" can't be compared in android? -


this question has answer here:

i think method displays "ok", in fact displays "fails". method b can correct result "ok".

i'm sure function fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css") return result "text/css".

i don't understand why method can't correct result. there bugs function fi.iki.elonen.nanohttpd.getmimetypeforfile ?

btw, method c can correct result "ok".

method a

string a="text/css"; string b= fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css");  utility.logerror("b: "+b);  if (a==b){     utility.logerror("ok"); }else{     utility.logerror("fails"); } 

method b

   string a="text/css";     string b= fi.iki.elonen.nanohttpd.getmimetypeforfile("my.css");      utility.logerror("b: "+b);      if (a.compareto(b)==0){         utility.logerror("ok");     }else{         utility.logerror("fails");     } 

method c

   string a="text/css";    string b= "text/css";      utility.logerror("b: "+b);      if (a==b){         utility.logerror("ok");     }else{         utility.logerror("fails");     } 

method 1

it results "fails" it because actual objects on heap getting compared when use == reference : detailed explanation

method 2

it results in ok , b contain same text(mime type) in them (using compare to)

method 3

it results in ok, expected.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo