// COBOL Programmers Swing With Java - copyright 2005 Doke, Hardgrave, & Johnson // Chapter 8 - Arrays // Program to demonstrate array search // ZipCodeProcessor.java 1 JAN 05 // program to exercise static method findZip in FindZipCode.java to demonstrate: // 1. array search // 2. static method // 3. passing array to method // 4. using arraay public attribute 'length' public class ZipCodeProcessor { public static void main(String args[]) { // declare & populate the array int zipCode [] ={30309,40410,41515,65757,72701}; int zipArgument; boolean foundIt; zipArgument = 65757; // we should find this value // call findZip method & pass zipArgument and zipCode array foundIt = FindZipCode.findZip (zipArgument, zipCode); if (foundIt) System.out.println ("We found " + zipArgument); else System.out.println ("We did NOT find " + zipArgument); // call findZip method again with a different argument zipArgument = 12345; // we should NOT find this value foundIt = FindZipCode.findZip (zipArgument, zipCode); if (foundIt) System.out.println ("We found " + zipArgument); else System.out.println ("We did NOT find " + zipArgument); } // end of main method } // end of ZipCodeProcessor.java