title: Java - Can you assign methods to an array?
body: <p>I'm a beginner to programming as a whole and I was wondering instead of typing what's given below, if there's a way you can assign these variable names into a String[] or making it to where I'm not typing the same code over and over again just with different variables?</p>
  
  <pre><code>  JButton one = new JButton("1");
    one.addActionListener(new Numbers());
    add(one);
  
    JButton two = new JButton("2");
    two.addActionListener(new Numbers());
    add(two);
  
    JButton three = new JButton("3");
    three.addActionListener(new Numbers());
    add(three);
  </code></pre>
  
  <p>Thanks!</p>