Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Finding the largest object in an array

  1. #1
    Member ashl7's Avatar
    Join Date
    Mar 2013
    Posts
    32
    My Mood
    Mellow
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Default 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
    Signature is:
    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?

    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] trouble finding object
    By dendoc01 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 10th, 2013, 06:16 AM
  2. 3x3 array find largest number
    By joecan2010 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 27th, 2012, 11:56 PM
  3. Finding the edges of object in photo
    By Picker in forum Algorithms & Recursion
    Replies: 1
    Last Post: April 20th, 2012, 11:32 PM
  4. Reading from ResultSet to Object and from object Object Array
    By anmaston in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 7th, 2011, 06:11 AM
  5. finding the largest object help
    By nickypass in forum Object Oriented Programming
    Replies: 4
    Last Post: October 16th, 2010, 05:48 PM