Java Reference
In-Depth Information
Modify the program in Figure 2.19 so that if no command-line argu-
ments are given, then the standard input is used.
2.10
Write a method that returns true if String str1 is a prefix of String str2 .
Do not use any of the general string searching routines except charAt .
2.11
Write a routine that prints the total length of the String s in a String[]
passed as a parameter. Your routine must work unchanged if the
parameter is changed to an ArrayList<String> .
2.12
What is wrong with this code?
2.13
public static void resize( int [ ] arr )
{
int [ ] old = arr;
arr = new int[ old.length * 2 + 1 ];
for( int i = 0; i < old.length; i++ )
arr[ i ] = old[ i ];
}
Implement the following methods, that accept an array of double and
return the sum, average, and mode (most common item) in the array.
2.14
public static double sum( double [ ] arr )
public static double average( double [ ] arr )
public static double mode( double [ ] arr )
Implement the following methods, that accept a two-dimensional
array of double and return the sum, average, and mode (most common
item) in the two-dimensional array.
2.15
public static double sum( double [ ][ ] arr )
public static double average( double [ ][ ] arr )
public static double mode( double [ ][ ] arr )
Implement the following methods that reverse an array or ArrayList
of String .
public static void reverse( String [ ] arr )
public static void reverse( ArrayList<String> arr )
2.16
Implement the following methods that return the minimum of the group
of items passed as the parameter. In the case of String s, the minimum is
the alphabetically smallest, as determined by compareTo .
2.17
public static int min( int [ ] arr )
public static int min( int [ ][ ] arr )
public static String min( String [ ] arr )
public static String min( ArrayList<String> arr )
Search WWH ::




Custom Search