lundi 7 décembre 2020

best type of Array for using the Iterator Pattern

First let me say that I am quiet new to Java, but not so new.

I am looking to build a restaurant menu application using the iterator pattern. So my question would be what would be the best array type to implement a 2D array with String name of item, Double Value?

Sample

ArrayList<String> menuItems;
 
    public PancakeHouseMenu() {
        menuItems = new ArrayList<String>();
        addItem("K&B's Pancake Breakfast",5);
String[][] menuItems;
public DinerMenu() {
        menuItems = new String[MAX_ITEMS];
        addItem("Vegetarian BLT",5);
        

or could I use Hashmaps if so what would be the most efficient in code and in runtime.

I am looking for insight into the greater picture for using arrays with the given scenario above.

Aucun commentaire:

Enregistrer un commentaire