// // ArrayTest - by Alan G. Labouseur // public class ArrayTest { public static void main(String[] args) { // Test an int array. int[] numbers = {3, 6, 9}; for( int val : numbers ) { System.out.println("The next value is " + val); } // Test a different int array. String[] items = new String[3]; items[0] = "Key"; items[1] = "Sword"; items[2] = "Map"; boolean hasKey = false; // Check for the key in the item collection. for( String item : items ) { if ( item.equalsIgnoreCase("Bottle") ) { hasKey = true; } } if (hasKey) { System.out.println("Key Found!"); } // Check out the args: System.out.println("args:"); for( String arg : args ) { try { int argAsInt = Integer.parseInt(arg); System.out.println("The arg is " + argAsInt); } catch (Exception e) { System.out.println("The arg is not really an int."); } } } }