generic method for linear search algorithm

Write a generic method for linear search algorithm.

Your algorithm should be able to search an element in an array of any type

as long as that type has Comparable interface implemented. The algorithm

should return the index, if the element exists and returns -1 otherwise.

Show that your method works by writing code for Circle class with

Comparable interface implemented (use radii of the circle for comparison),

and then search for a particular circle object in your array.

public static void main(String[] args) {

Circle[] array = {new Circle(10), new Circle(30),

new Circle(40), new Circle(100)};

// should print 1

System.out.println(search(array, new Circle(30)));

// should print -1

System.out.println(search(array, new Circle(300)));

}