What would be a better alternative (simplest) to compress my code in the example below?
I'm thinking there could be a way to loop or array these. When I tried to put them in an array, the syntax errors out. Maybe arrayList or treeMap would be a better approach? I'm a little rusty with those structures. Am I looking to deep into this?
private JMenuItem one = new JMenuItem("One");
private JMenuItem two = new JMenuItem("Two");
//... = ...;
//... = ...;
private JMenuItem sixtySeven = new JMenuItem("Sixty Seven");
for(conditions or array looping)
{
private JMenuItem i = new JMenuItem(i.toString().proper());//I have to research if there is even a "proper" method.
}
//Revised example below:
private JMenu edit = new JMenu("Edit");
private JMenu format = new JMenu("Format");
private JMenu view = new JMenu("View");
private JMenu help = new JMenu("Help");
private JMenuItem save = new JMenuItem("Save");
private JMenuItem open = new JMenuItem("Open");
private JMenuItem exit = new JMenuItem("Exit");