Finding the mean of all of the integers in an ArrayList : I am currently making a simulator for fake basketball players but am currently stuck on finding the mean of all of the numbers in the arraylist.  I know how to add all of them up but when ever I try to make a counter variable to divide the list or list.getSize() non of them work. Hopefully this makes sense to you, I am happy to explain in more detail the problem.

        
    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.Font;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;

    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JTextPane;
    import javax.swing.SwingConstants;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;

    public class Application {

	private JFrame frame;
	private JTextField pst;
	private JTextField pg;
	private JTextField sg;
	private JTextField pf;
	private JTextField C;
	private JTextField sf;
	private JTextField txtPlayerName;
	private JTextField ED;
	private JTextField CJ;
	private JTextField SB;
	private JTextField SW;
	private JTextField JO;
	private JTextField num;
	private JTextField edNum;
	private JTextField cjNum;
	private JTextField sbNum;
	private JTextField swNum;
	private JTextField joNum;
	private JTextField ppg;
	private JTextField ppgED;
	private JTextField ppgCJ;
	private JTextField ppgSB;
	private JTextField ppgJO;
	private JTextField ppgSW;
	private JButton btnPlay;
	private List<Integer> ppgList;
	private int sum;
	private int counter;

	// Launch the application.
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Application window = new Application();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Application() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		initComponenets();
		createEvents();
	}

	////////////////////////////////////////////////////////////////////////
	//Contains all of the code for creating events
	private void createEvents() {
		
	}
	//Contains all of the code for creating and initializing components
	private void initComponenets() {
		
		////////////////////////////////////////////////////////////Frame
		frame = new JFrame();
		frame.setTitle("Title");
		frame.setBounds(100, 100, 801, 450);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		////////////////////////////////////////////////////////////Title
		JTextPane title = new JTextPane();
		title.setBackground(Color.LIGHT_GRAY);
		title.setEditable(false);
		title.setFont(new Font("Tahoma", Font.PLAIN, 20));
		title.setForeground(Color.DARK_GRAY);
		title.setBounds(237, 11, 296, 50);
		title.setText("   Basketball Simulation Game");
		frame.getContentPane().add(title);
		
    /////////////////////////////////////////////////////////// Position TextBox
		pst = new JTextField();
		pst.setHorizontalAlignment(SwingConstants.CENTER);
		pst.setEditable(false);
		pst.setFont(new Font("Tahoma", Font.BOLD, 14));
		pst.setText("PST");
		pst.setBounds(10, 64, 50, 35);
		frame.getContentPane().add(pst);
		pst.setColumns(10);
		
		pg = new JTextField();
		pg.setHorizontalAlignment(SwingConstants.CENTER);
		pg.setText("PG");
		pg.setFont(new Font("Tahoma", Font.BOLD, 14));
		pg.setEditable(false);
		pg.setColumns(10);
		pg.setBounds(10, 99, 50, 50);
		frame.getContentPane().add(pg);
		
		sg = new JTextField();
		sg.setHorizontalAlignment(SwingConstants.CENTER);
		sg.setText("SG");
		sg.setFont(new Font("Tahoma", Font.BOLD, 14));
		sg.setEditable(false);
		sg.setColumns(10);
		sg.setBounds(10, 148, 50, 50);
		frame.getContentPane().add(sg);
		
		sf = new JTextField();
		sf.setText("SF");
		sf.setHorizontalAlignment(SwingConstants.CENTER);
		sf.setFont(new Font("Tahoma", Font.BOLD, 14));
		sf.setEditable(false);
		sf.setColumns(10);
		sf.setBounds(10, 196, 50, 50);
		frame.getContentPane().add(sf);
		
		pf = new JTextField();
		pf.setText("PF");
		pf.setHorizontalAlignment(SwingConstants.CENTER);
		pf.setFont(new Font("Tahoma", Font.BOLD, 14));
		pf.setEditable(false);
		pf.setColumns(10);
		pf.setBounds(10, 242, 50, 50);
		frame.getContentPane().add(pf);
		
		C = new JTextField();
		C.setText("C");
		C.setHorizontalAlignment(SwingConstants.CENTER);
		C.setFont(new Font("Tahoma", Font.BOLD, 14));
		C.setEditable(false);
		C.setColumns(10);
		C.setBounds(10, 291, 50, 50);
		frame.getContentPane().add(C);
		
		
		/////////////////////////////////////////////// PlayerName
		txtPlayerName = new JTextField();
		txtPlayerName.setText("Player Name");
		txtPlayerName.setHorizontalAlignment(SwingConstants.CENTER);
		txtPlayerName.setFont(new Font("Tahoma", Font.BOLD, 14));
		txtPlayerName.setEditable(false);
		txtPlayerName.setColumns(10);
		txtPlayerName.setBounds(59, 64, 95, 35);
		frame.getContentPane().add(txtPlayerName);
		
		ED = new JTextField();
		ED.setText("ED");
		ED.setHorizontalAlignment(SwingConstants.CENTER);
		ED.setFont(new Font("Tahoma", Font.BOLD, 14));
		ED.setEditable(false);
		ED.setColumns(10);
		ED.setBounds(59, 99, 95, 50);
		frame.getContentPane().add(ED);
		
		CJ = new JTextField();
		CJ.setText("CJ");
		CJ.setHorizontalAlignment(SwingConstants.CENTER);
		CJ.setFont(new Font("Tahoma", Font.BOLD, 14));
		CJ.setEditable(false);
		CJ.setColumns(10);
		CJ.setBounds(59, 148, 95, 50);
		frame.getContentPane().add(CJ);
		
		SB = new JTextField();
		SB.setText("SB");
		SB.setHorizontalAlignment(SwingConstants.CENTER);
		SB.setFont(new Font("Tahoma", Font.BOLD, 14));
		SB.setEditable(false);
		SB.setColumns(10);
		SB.setBounds(59, 196, 95, 50);
		frame.getContentPane().add(SB);
		
		SW = new JTextField();
		SW.setText("Swanigan");
		SW.setHorizontalAlignment(SwingConstants.CENTER);
		SW.setFont(new Font("Tahoma", Font.BOLD, 14));
		SW.setEditable(false);
		SW.setColumns(10);
		SW.setBounds(59, 245, 95, 47);
		frame.getContentPane().add(SW);
		
		JO = new JTextField();
		JO.setText("Jordan");
		JO.setHorizontalAlignment(SwingConstants.CENTER);
		JO.setFont(new Font("Tahoma", Font.BOLD, 14));
		JO.setEditable(false);
		JO.setColumns(10);
		JO.setBounds(59, 291, 95, 50);
		frame.getContentPane().add(JO);
		
		/////////////////////////////////////////////Numbers
		num = new JTextField();
		num.setText("#");
		num.setHorizontalAlignment(SwingConstants.CENTER);
		num.setFont(new Font("Tahoma", Font.BOLD, 14));
		num.setEditable(false);
		num.setColumns(10);
		num.setBounds(153, 64, 50, 35);
		frame.getContentPane().add(num);
		
		edNum = new JTextField();
		edNum.setText("0");
		edNum.setHorizontalAlignment(SwingConstants.CENTER);
		edNum.setFont(new Font("Tahoma", Font.BOLD, 14));
		edNum.setEditable(false);
		edNum.setColumns(10);
		edNum.setBounds(153, 99, 50, 50);
		frame.getContentPane().add(edNum);
		
		cjNum = new JTextField();
		cjNum.setText("3");
		cjNum.setHorizontalAlignment(SwingConstants.CENTER);
		cjNum.setFont(new Font("Tahoma", Font.BOLD, 14));
		cjNum.setEditable(false);
		cjNum.setColumns(10);
		cjNum.setBounds(153, 148, 50, 50);
		frame.getContentPane().add(cjNum);
		
		sbNum = new JTextField();
		sbNum.setText("24");
		sbNum.setHorizontalAlignment(SwingConstants.CENTER);
		sbNum.setFont(new Font("Tahoma", Font.BOLD, 14));
		sbNum.setEditable(false);
		sbNum.setColumns(10);
		sbNum.setBounds(153, 196, 50, 50);
		frame.getContentPane().add(sbNum);
		
		swNum = new JTextField();
		swNum.setText("8");
		swNum.setHorizontalAlignment(SwingConstants.CENTER);
		swNum.setFont(new Font("Tahoma", Font.BOLD, 14));
		swNum.setEditable(false);
		swNum.setColumns(10);
		swNum.setBounds(153, 245, 50, 47);
		frame.getContentPane().add(swNum);
		
		joNum = new JTextField();
		joNum.setText("23");
		joNum.setHorizontalAlignment(SwingConstants.CENTER);
		joNum.setFont(new Font("Tahoma", Font.BOLD, 14));
		joNum.setEditable(false);
		joNum.setColumns(10);
		joNum.setBounds(153, 291, 50, 50);
		frame.getContentPane().add(joNum);
		
		//////////////////////////////////Points per game
		ppg = new JTextField();
		ppg.setText("PPG");
		ppg.setHorizontalAlignment(SwingConstants.CENTER);
		ppg.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppg.setEditable(false);
		ppg.setColumns(10);
		ppg.setBounds(201, 64, 50, 35);
		frame.getContentPane().add(ppg);
		
		ppgED = new JTextField();
		ppgED.setText("0.0");
		ppgED.setHorizontalAlignment(SwingConstants.CENTER);
		ppgED.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppgED.setEditable(false);
		ppgED.setColumns(10);
		ppgED.setBounds(201, 99, 50, 50);
		frame.getContentPane().add(ppgED);
		
		ppgCJ = new JTextField();
		ppgCJ.setText("0.0");
		ppgCJ.setHorizontalAlignment(SwingConstants.CENTER);
		ppgCJ.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppgCJ.setEditable(false);
		ppgCJ.setColumns(10);
		ppgCJ.setBounds(201, 148, 50, 50);
		frame.getContentPane().add(ppgCJ);
		
		ppgSB = new JTextField();
		ppgSB.setText("0.0");
		ppgSB.setHorizontalAlignment(SwingConstants.CENTER);
		ppgSB.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppgSB.setEditable(false);
		ppgSB.setColumns(10);
		ppgSB.setBounds(201, 196, 50, 50);
		frame.getContentPane().add(ppgSB);
		
		ppgJO = new JTextField();
		ppgJO.setText("0.0");
		ppgJO.setHorizontalAlignment(SwingConstants.CENTER);
		ppgJO.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppgJO.setEditable(false);
		ppgJO.setColumns(10);
		ppgJO.setBounds(201, 291, 50, 50);
		frame.getContentPane().add(ppgJO);
		
		ppgSW = new JTextField();
		ppgSW.setText("0.0");
		ppgSW.setHorizontalAlignment(SwingConstants.CENTER);
		ppgSW.setFont(new Font("Tahoma", Font.BOLD, 14));
		ppgSW.setEditable(false);
		ppgSW.setColumns(10);
		ppgSW.setBounds(201, 245, 50, 47);
		frame.getContentPane().add(ppgSW);
		
		////////////////////////////////////////Play JButton
		btnPlay = new JButton("PLAY");
		btnPlay.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getPPG(33, ppgED);
			}
		});
		btnPlay.setFont(new Font("Tahoma", Font.PLAIN, 24));
		btnPlay.setBounds(304, 344, 160, 56);
		frame.getContentPane().add(btnPlay);
		
		
		
		
	}
	
	public void getPPG(int num, JTextField box){
		
		Random rand = new Random();
		String text;
		ppgList = new ArrayList<Integer>();
		
		for(int xy = 0; xy < 1; xy++){
			
			num = num + rand.nextInt(10);
			ppgList.add(num);
			
		}

	    for(int i = 0; i < ppgList.size(); i++)
	    {
	    	counter++;
	        sum = sum + ppgList.get(i) / counter;
	    }
		Integer.toString(sum);
		text = String.valueOf(sum);
		box.setText(text);
	}
	
}
