Java code is equivalent to the following PHP code
•
Java
The following PHP syntax may be Java equivalent:
$newPerson = array(
'firstname' => 'First','lastname' => 'Last','email' => 'test@example.com',);
I think here firstname is the index of the array and first is the value of the index How to define such an array in Java?
Solution
Map<String,String> newPerson = new HashMap<String,String>()
Map<String,String> newPerson = new HashMap<String,String>()
{{
put("firstname","First");
put("lastname","Last");
put("email","test@example.com");
}};
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
