Php array_push function in java -


i trying rewrite following php code in java

   foreach ($configvalues $data) {     $temp['config_key'] = is_null($data->getconfigkey()) ? '' : $data->getconfigkey();     $temp['config_value'] = is_null($data->getconfigvalue()) ? '' : $data->getconfigvalue();     array_push($configarray, $temp); } foreach ($configpricing $data) {     $temp1['config_key'] = is_null($data->gettype()) ? '' : $data->gettype();         $temp1['config_value'] = is_null($data->getprice()) ? '' : $data->getprice();         array_push($configarray, $temp1);     } 

the above code push 1 associative array in how can in write in java tried in way :

list<string> configlist=new arraylist();          list<config> config=configrepository.findall();         system.out.println("config size:"+config.size());         list<configpricing> configpricing=configpricingrepository.findall();         system.out.println("configpricing size:"+configpricing.size());          map<string, string> response = new hashmap<string, string>();            listmultimap<string, string> temphashmap = arraylistmultimap.create();               arraylist configarray = new arraylist();                for(config data:config){              if(data.getconfigkey() !=null && !"".equals(data.getconfigkey()))             temphashmap.put("config_key", data.getconfigkey() );              if(data.getconfigvalue() !=null && !"".equals(data.getconfigvalue()))             temphashmap.put("config_value", data.getconfigvalue().isempty() ? "" : data.getconfigvalue());          } //      configarray.add(temphashmap);          for(configpricing configpricingdata:configpricing){             if(configpricingdata.gettype() !=null && !"".equals(configpricingdata.gettype()))             temphashmap.put("config_key", configpricingdata.gettype().isempty() ? "" : configpricingdata.gettype() );              if(configpricingdata.getprice() !=null && !"".equals(configpricingdata.getprice()))             temphashmap.put("config_value", configpricingdata.getprice().tostring().isempty() ? "":configpricingdata.getprice().tostring()); //          configarray.add(temphashmap);          } 

but storing data this:

samekey1:valueone,valuetwo ,talue theree, samekey2:valueone,valuetwo ,talue theree,

insted of store in following way:

samekey1:value samekey2:value   samekey1:value  samekey2:value   samekey1:value  samekey2:value  

this may useful,

// no key array_push($configarray, $value); // same as: $configarray[] = $value;  // key known $configarray[$samekey1] = $value; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -