Im having a refrencing problem that i am not too sure how to deal with. When i return an Object array from a method what do i store it in? As an example i have a simple method that when invoked creates a new Object array and adds new instances of other Objects(JButtons) to a JPanel then returns the JButton[] array. When the method returns what to i store the returned refrence in? passDigits(digits) is passing a null Object array.
Code:
class X{
 JButton[] digits;
 JPanel dig = new JPanel();
 digits = addDigits(dig);
 passDigits(digits);
}
Code:
public JButton[] addDigits(JPanel dig){
    JButton[] digits = new JButton[10];
    for(int i = 9; i <= 0; --i){
        digits[i] = new JButton(String.valueOf(i));
        dig.add(digits[i]);
      }
       return digits;
}