I'm having some problems automatically populating two arrays using for loop. I know how to do it manually but it's obviously not the right way. now the code looks like that:
Scanner scan = new Scanner(System.in);
String [] allStockCodes = new String [5];
int [] stockPrices = new int [5];
Stock s0 = new Stock ("TEVA", 100);
Stock s1 = new Stock ("APPLE", 45);
Stock s2 = new Stock ("GOOGLE", 765);
Stock s3 = new Stock ("IBM", 76);
Stock s4 = new Stock ("MICROSOFT", 436);
allStockCodes[0] = s0.getCode();
allStockCodes[1] = s1.getCode();
allStockCodes[2] = s2.getCode();
allStockCodes[3] = s3.getCode();
allStockCodes[4] = s4.getCode();
stockPrices[0] = s0.getPrice();
stockPrices[1] = s1.getPrice();
stockPrices[2] = s2.getPrice();
stockPrices[3] = s3.getPrice();
stockPrices[4] = s4.getPrice();
as you can see there are two arrays, one needed to be populated with string and the other with int. I'm using two constructors the get the string (getCode) and the int (getPrice). So how do I build the loop correctly?