What would be Java equivalent for php array like this:
$user = array("name" => "John", "email" => "[email protected]");
You can use a HashMap or a Hashtable. Not sure which one to use? Read the API or check out 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", "[email protected]");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With