Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

C30N9

Members
  • Content count

    1331
  • Joined

  • Last visited

5 Followers

About C30N9

  • Rank
    Senior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Single Status Update

See all updates by C30N9

  1. 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:

    code:
    Array
    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?

    1. TwinBeast

      TwinBeast

      Maybe it's slow? I did something like that to find the closest color from a 256 palette as a glsl shader and it made the game run 1 to 5 fps.

    2. AndrewB

      AndrewB

      Your solution is better. Tell your friend that he's stupid.

    3. Cacatou

      Cacatou

      If your class doesn't have the compareTo function then your method won't work but assuming that all your classes have compareTo then your method will work perfectly.

×