I created a custom 'text menu' that should print each String passed to it.
This is the class:
package com.github.geodox.areacalculator.menu;
public class Menu
{
private static int index = 0;
private static String[] menuItems;
public void addItem(String menuItem)
{
menuItems = new String[index+1];
menuItems[index] = menuItem;
index++;
}
public void printMenu()
{
for(String menuItem : menuItems)
{
System.out.println(menuItem);
}
}
}
This is what is passed.
Menu menu = new Menu();
menu.addItem("rectangle");
menu.addItem("square");
menu.addItem("circle");
menu.addItem("triangle");
menu.addItem("trapezoid");
menu.addItem("parallelogram");
menu.printMenu();
However, this is what is printed:
null
null
null
null
null
parallelogram
Any ideas on why this is happenning?