Finding the largest object in an array
Hi, I have this exercise and kinda confuses me...I needed some help from professionals to clear things up for me(this is a school project, we haven't finished the course yet, so maybe some of the expressions we haven't even covered yet... since I'm on spring break, I can't ask my teacher about it, but need to do it now, so will appreciate any help)
I'm not sure if I have to ask for it here, since you didn't make the problem, but you probably have some ideas...share those ideas(*)
Finding the largest object
Write a method that returns the largest objects in an array of objects. The method
public static Object max( Comparable a)
All objects are instance of the Comparable interface. The order of objects in array is determined using compareTo method.
Write a test program( Deriver) that creates array of ten Strings, MRects and Dates, and find the largest String, MRect and Date in the array.
first of all, what kind of object are we talking about?! is it Strings, Integers?! Or should I write a method that covers all types of objects?
in this line: public static Object max( Comparable a)
what is Object(does it mean String, Int...), and what does Comparable refer to?!
"The order of objects in array is determined using compareTo method." what good is this line for?
what is a test program or deriver as he says?!
what is MRects?
Re: Finding the largest object in an array
Q: what kind of object
A: All objects are instance of the Comparable interface
Q: what is Object
A: A java class defined in the API doc. See: Java Platform SE 7
Q:what does Comparable refer to
A: A java interface. See the API doc
Q: compareTo method." what good is this line for?
A: Read the API doc for the method
A test drive would be a method that calls all the methods with different data and prints the results too see if the methods did what was required. Often a main() method in a class is used.