"John",...">All geek questions in one placeWhat is the Java equivalent for a PHP array with non-numeric keys?What is the Java equivalent for php array:$user = array("name" => "John", "email" => "john@mail.com"); +3java arrays hashmap phpbancer Dec 16 '10 at 22:02source share7 answersYou can use HashMap or Hashtable . Not sure which one to use? Read the API or see this question , which discusses the pros and cons of each.HashMap<String, String> map = new HashMap<String, String>(); map.put("name", "John"); map.put("email", "john@mail.com"); +7Catchwa Dec 16 '10 at 10:06source shareThe implementation of the Map interface is the equivalent of a Java associative array, but it looks like what you really want is a user class with fields for name and email.+6Nick Dec 16 '10 at 22:07source share, PHP , . , foreach , .Java, , LinkedHashMap.+5JW. 16 . '10 22:12LinkedHashMap. HashMap , . HashMap , .Map<String, String> map = new LinkedHashMap<String, String>(); map.put("name", "John"); map.put("email", "john@mail.com"); +3Peter Lawrey 16 . '10 22:14java.util.HashMap+2Mchl 16 . '10 22:05http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html, http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html.+1Chocula 16 . '10 22:04Map user = new HashMap(); user.put("name", "John"); user.put("email", "john@mail.com"); +1Alexander Wallin 16 . '10 22:06Source: https://habr.com/ru/post/1780771/More articles:Zend Framework Session Lost - phpSample Android using H2 - androidOpengl polygons - renderingИспользование Caliburn.Micro для привязки к под-свойствам - silverlightWhen someone picked a cherry from my git, commits and commits their own actions, how do I merge? - gitvoice over internet iphone sdk - iphoneSaving and retrieving an image using Qt - qteBay API - Filter Items by Shopping / Custom Categories - ebaySearch for old .Net librairies - .netThe right way to stop with MPI - fortranAll Articles
What is the Java equivalent for php array:
$user = array("name" => "John", "email" => "john@mail.com");
You can use HashMap or Hashtable . Not sure which one to use? Read the API or see this question , which discusses the pros and cons of each.
HashMap<String, String> map = new HashMap<String, String>(); map.put("name", "John"); map.put("email", "john@mail.com");
The implementation of the Map interface is the equivalent of a Java associative array, but it looks like what you really want is a user class with fields for name and email.
, PHP , . , foreach , .
foreach
Java, , LinkedHashMap.
LinkedHashMap. HashMap , . HashMap , .
Map<String, String> map = new LinkedHashMap<String, String>(); map.put("name", "John"); map.put("email", "john@mail.com");
java.util.HashMap
http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html, http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html.
Map user = new HashMap(); user.put("name", "John"); user.put("email", "john@mail.com");
Source: https://habr.com/ru/post/1780771/More articles:Zend Framework Session Lost - phpSample Android using H2 - androidOpengl polygons - renderingИспользование Caliburn.Micro для привязки к под-свойствам - silverlightWhen someone picked a cherry from my git, commits and commits their own actions, how do I merge? - gitvoice over internet iphone sdk - iphoneSaving and retrieving an image using Qt - qteBay API - Filter Items by Shopping / Custom Categories - ebaySearch for old .Net librairies - .netThe right way to stop with MPI - fortranAll Articles