Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Convert php to java/android arrays -


$tagarray = array(     "apples" => 12,     "oranges" => 38,     "pears" => 10,     "mangos" => 24,     "grapes" => 18,     "bananas" => 56,     "watermelons" => 80,     "lemons" => 12,     "limes" => 12,     "pineapples" => 15,     "strawberries" => 20,     "coconuts" => 43,     "cherries" => 20,     "raspberries" => 8,     "peaches" => 25     ); 

how can in java, , how calling first , second params?

java has no built in support associative arrays. corresponding datastructure in java map. in case instance make use of hashmap.

here's 1 way.

map<string, integer> tagarray = new hashmap<string, integer>() {{     put("apples", 12);     put("oranges", 38);     put("pears", 10);     put("mangos", 24);     put("grapes", 18);     put("bananas", 56);     put("watermelons", 80);     put("lemons", 12);     put("limes", 12);     put("pineapples", 15);     put("strawberries", 20);     put("coconuts", 43);     put("cherries", 20);     put("raspberries", 8);     put("peaches", 25); }}; 

to value for, say, "lemons" do

int value = tagarray.get("lemons"); 

as @peter lawrey points out in comments: if order in array important you, use linkedhashmap instead of hashmap.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -