1204 Collections Chapter 21 6 7 public class (Web hosting directory)
1204 Collections Chapter 21 6 7 public class UsingArrays { 8 private int intValues[] = { 1, 2, 3, 4, 5, 6 }; 9 private double doubleValues[] = { 8.4, 9.3, 0.2, 7.9, 3.4 }; 10 private int filledInt[], intValuesCopy[]; 11 12 // initialize arrays 13 public UsingArrays() 14 { 15 filledInt = new int[ 10 ]; 16 intValuesCopy = new int[ intValues.length ]; 17 18 Arrays.fill( filledInt, 7 ); // fill with 7s 19 20 Arrays.sort( doubleValues ); // sort doubleValues 21 22 System.arraycopy( intValues, 0, intValuesCopy, 23 0, intValues.length ); 24 } 25 26 // output values in each array 27 public void printArrays() 28 { 29 System.out.print( “doubleValues: ” ); 30 31 for ( int count = 0; count < doubleValues.length; count++ ) 32 System.out.print( doubleValues[ count ] + " " ); 33 34 System.out.print( "nintValues: " ); 35 36 for ( int count = 0; count < intValues.length; count++ ) 37 System.out.print( intValues[ count ] + " " ); 38 39 System.out.print( "nfilledInt: " ); 40 41 for ( int count = 0; count < filledInt.length; count++ ) 42 System.out.print( filledInt[ count ] + " " ); 43 44 System.out.print( "nintValuesCopy: " ); 45 46 for ( int count = 0; count < intValuesCopy.length; count++ ) 47 System.out.print( intValuesCopy[ count ] + " " ); 48 49 System.out.println(); 50 } 51 52 // find value in array intValues 53 public int searchForInt( int value ) 54 { 55 return Arrays.binarySearch( intValues, value ); 56 } 57 Fig. 21.1Using methods of class Arrays(part 2 of 3). Fig. 21.1 Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/12/01
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services