标签: java php arrays
我有一个PHP代码:
$array['cows'] = 4; $array['horses'] = 7; $array['cats'] = 9; $array['dogs'] = 2; arsort($array);
如何用Java做到这一点?
'print_r($ array);'的排序(从最大值)输出是:
Array ( [cats] => 9 [horses] => 7 [cows] => 4 [dogs] => 2 )
答案 0 :(得分:0)
对于PHP关联数组,您应该在Java(HashMap或TreeMap)中使用Map类型。对此article