So, I initialized it as an array object, and when I go to initialize the individual objects,it won't give them a value
/*
-A java program GUI for Food to allow user to type the food
*/
public class Catagorygui extends JFrame implements ActionListener{
//attributes
JPanel panel;
JButton button;
JFrame frame;
JLabel item;
JTextField item1;
JLabel cost;
JTextField cost1;
JLabel percentused;
JLabel name;
JTextField name1;
JLabel paidupfront;
JTextField paidupfront1;
public Appartment2 g=new Appartment2();
private static String rec=" ";
private JTextField [] upfront=new JTextField[g.getPeople().size()];//must initialize
private JTextField [] percent=new JTextField[g.getPeople().size()];
private JLabel [] usernames=new JLabel[g.getPeople().size()];//for loop that gives them values
private int a;
public Catagorygui (){
g.addPerson("Ali");
g.addPerson("Kacie");
for(int i=0;i<a;i++)
{
usernames[i]=new JLabel("poop");//somehow not initializing it
percent [i]=new JTextField(10);
upfront [i]=new JTextField(10);
percent[i].addActionListener(this);
}
System.out.println(g.getpeople().get(0).getName());//ali
System.out.print(usernames[0]);//SAYS INDEX OUT OF BOUNDS, should say'poop'
//
a=g.getpeople().size();
usernames[0]throws index out of bounds, that means the array size is0.