Is there an equivalent function to array_keys in Java?
Either in the form of arrays or array lists.
The Map collection has a keySet() method, and I think that's the closest thing to PHP's associative arrays in Java.
Well, in Java I think the only way to have non integer keys is to use the Map class:
http://download.oracle.com/javase/6/docs/api/java/util/Map.html
And as you can see it has a keySet function.
http://download.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html#keySet()
This returns you a Java Set of the keys :)
Another way is to iterate the Map and store the keys in Array/ArrayList
Let me see if got this right, i know that php arrays have keys and values, nevertheless in java thins does not work like that arrays and list are index base, this means that your keys are just index in natural order. if you can shared some code to look what do you exactly need that would be perfect, but in the mean time you might use Map
Map<String,String> hashMap = new HashMap<String,String>();
hashMap.put("Key1","Value1");
hashMap.put("Key2","Value2");
hashMap.put("Key3","Value3");
hashMap.put("Key4","Value4");
then you can use keySet() method to get the keys.