Hey im working on a code where i need to get a certain column of a 2d array and create a 1d array with the information.
The information im using is a product list in an aray in thsi format [barcode][price][stock]
Now i need to grab the bar codes of the files that are under a certain stock.
I have so far manged to get my code to output the barcodes that are understocked but cannot work out how to put them into an array.
Heres my code so far:
public long[] understockedProductBarcodes(){
long minStockLevel = 500;
int maxElements = productBarcodeList.length;
long[] understockedBarcode;
understockedBarcode = new long[maxElements];
int totalColumns = 3;
int r = 0;
int c = 0;
for (r = 0; r < productBarcodeList.length; r++){
for (c = 2; c < totalColumns; c++){
if (productBarcodeList[r][c] > 0){
if (productBarcodeList [r][c] < minStockLevel){
System.out.println(productBarcodeList[r][0]);
}
}
}
}
return understockedBarcode;
}