// COBOL Programmers Swing With Java - copyright 2005 Doke, Hardgrave, & Johnson // Chapter 8 - Arrays // Program to demonstrate array search // FindZipCode.java 1 JAN 05 public class FindZipCode { // findZip() accepts argument & array - returns boolean true or false public static boolean findZip (int zipToFind, int []zipCode) { int index = 0; boolean foundIt = false; while (index < zipCode.length && !foundIt) // loop until found or end { if (zipToFind == zipCode [index]) // compare the argument to this element value foundIt = true; // set switch to true if we have a match else index = index + 1; // else, keep looking } // end of loop return foundIt; } // end of findZip method } // end of FindZipCOde.java