getting error when compiling.
"java:60: non-static variable inventory cannot be referenced from a static context for (String show : ProductDB.inventory)"
the showCodes class has to public static void. Here is code
import java.util.*;
import java.text.*;
public class ProductApp
{
public static void main(String args[])
{
// display a weclome message
System.out.println(" Welcome to the Product Selector\n");
// perform 1 or more selections
Scanner sc = new Scanner(System.in);
String choice = "y";
while (choice.equalsIgnoreCase("y"))
{
System.out.print(" Enter product code or X to Exit: ");
String productCode = sc.next(); // read the product code
sc.nextLine(); // discard any other data entered on the line
// see if the user wants to continue
if ("x".equals(productCode)||("X".equals(productCode))) {
System.out.printf("\n");
System.out.printf(" Program terminated by the user ...\n");
System.out.printf("\n");
break;
}
else {
// get the Product object
Product p = ProductDB.getProduct(productCode);
// display the output
System.out.println();
if (p != null)
System.out.println(p.toString());
else
System.out.println(" No product matches this product code.\n");
System.out.println(" Product count: " + Product.getCount() + "\n");
// see if the user wants to continue
showCodes();
System.out.println();
//System.out.print(" Continue? (y/n): ");
//choice = sc.nextLine();
System.out.println();
} // end if
} // end while
} // end main
public static void showCodes()
{
System.out.println(" You have these product codes to choose from:\t");
for (String show : ProductDB.inventory)
{
System.out.print(show + " ");
} // end for loop
} // end showCodes method
} // end class ProductApp