-
Content count
1331 -
Joined
-
Last visited
Single Status Update
-
I've been asked to write a method which is public static Object max(Object[] a). It should return the highest Object in an Object array using compareTo method. However, with this method's parameter, since Object doesn't have compareTo method, I'm supposed to put several if statements to determine if the object is an instanceof Account, or Employee, or other classes that use compareTo:
So I changed the function to this:code:
Array
Which works fine, and I think it's similar to java.util.Arrays.max(anArray). But I heard that it's not a very good idea to do that. Is it healthy to do this?code:
Array