Can Java use a String as an index array key? Example:
array["a"] = 1;
No, that would be a Map in Java. (The type would be Map<String,Integer> .)
Actually, it has very much to do with the question (specifically, yes, you CAN use a string as an index, but not in the obvious way that the original querier wants).
String class split(String regex) can be used to convert String to array in java. If you are working with java regular expression, you can also use Pattern class split(String regex) method.
No.
To do something like this, you have to use a Map.
Map<String, Integer> aMap = new HashMap<String, Integer>(); aMap.put("a" , Integer.valueOf(1));
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