I'm new to Java, and little bit confused with arrays. It's easy to do it in PHP, but it is different in Java.
I need to create an array, like the one listed below, and print it using "for" loops. Could you please help me with that. Thanks in advance.
myCatsAndSubcats = array(
"Books" => array(
"Book1", "Book2", "Book3"
"Food" => array(
"Food1", "Food2", "Food3"
"Medical" => array(
"Pills1", "Pills2", "Pills3"
I guess I need something like Hashtable<String, ArrayList<String>> myCategories = new Hashtable<String, ArrayList<String>>();
So now I need to add several categories(to be precise, "Books", "Food", "Medical"), and for each particular category I need to add the list of its subcategories.
Do I need to fill categories first, with elements (Book, Food, Medicals), and than use put() method for each one?
How do I actually add elements to categories?
I feel like a dummy in Java.
That's why I just need a working example (an array, mentioned above as well as its printout), so I can review the code, understand what exactly does that code and write my own, with changes.
Tried to find some examples for my particular problem, but no luck.