java - Array confusion -


I am not a programmer and I am having problems with my code. I get an error:

  `java.lang.ArrayIndexOutOfBoundsException: 0`   

Some help would be appreciated. Thank you.

My code:

  Import java.util.Scanner; Public grade gradebook 1d {public static zero main (string [] args) {scanner input = new scanner (System.in); Int [] ID = new int [0]; Double [] quiz 1 = new double [0]; Double [] quiz 2 = new double [0]; Double [quiz 3 = new double [0]; Int idStudent = 0; System.out.print ("Enter how students are in your class:"); IdStudent = input.nextInt (); Double [] yoga = new double [0]; {System.out.println ("Enter student ID") for (Int id = 0; I & lt; idStudent; i ++); Id [i] = input.nextInt (); System.out.print ("Enter the score for quiz 1"); Quiz 1 [I] = Input NXIT (); System.out.print ("Enter the score for quiz 2"); Quiz 2 [i] = input.nextInt (); System.out.print ("Enter the score for quiz 3"); Quiz 3 [i] = input.nextInt (); Yoga [i] = quiz 1 [i] + quiz 2 [i] + quiz 3 [i]; }}}}    

You are starting with an array of zero size when < code> new int [0] , new double [0], etc ... After setting the size of the array, find out how long it should be:

  scanner Input = new scanner (System.in); System.out.print ("Enter how students are in your class:"); Int idStudent = input.nextInt (); Int [] id = new id [idStudent]; Double [quiz 1 = new double [idStudent]; Double [quiz 2 = new double [idStudent]; Double [quiz 3 = new double [idStudent]; Double [] yoga = new double [idStudent]; For the     (int i = 0; i 

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -