Homework #1

4.42, page 179

problem text


Hint:

1. submit ONE file through uploading Canvass e.g. YourLoginUsername_hwk1.java

2. Before submit, test on linux: first on a lab computer double click "WinScp" icon and type " linux.uncg.edu" in hostname, and enter user name and password, and transfer your file; then double click "Putty" icon enter above hostname, user name and password. In the coomand line type "javac filename" and "./a.out"

3. In whatever ways first let the program pass compilation and running.

skeleton (one possible idea/sol. only as hint or reference):



class hwk1 {

public static <T> boolean contains(T[] input, Check<T> c) {
       ... c.ok(input[i]) ...
    }

static public interface Check<T> {
      
        boolean ok( T item); //item T is ok (negative e.g.)
    }
 
static public class Negative implements Check<Integer> {
        public boolean ok( Integer val) {
            return val < 0;
        }
    }

main(){...}

}



}