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: Min/Max of fields

  1. #1
    Junior Member jbraque's Avatar
    Join Date
    May 2013
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Min/Max of fields

    Hello people,
    Let's say i have an object with some fields. How can i create a class objectList that can calculate the statistics of the these objects?
    For example i have object.fieldname and i want objectList.fieldname.min.
    Thank you!


  2. #2
    Member angstrem's Avatar
    Join Date
    Mar 2013
    Location
    Ukraine
    Posts
    200
    My Mood
    Happy
    Thanks
    9
    Thanked 31 Times in 29 Posts

    Default Re: Min/Max of fields

    You can create a Comparator to compare objects so, that the object with smaller field A would be considered smaller. Then you can compose a collection or an array and sort it with this comparator. As a result, you'll get a collection where object are sorted corresponding to field A in ascending order.

Similar Threads

  1. Multi-D array. daily max/min/avg, weekly max/min/avg, sum total (99% done)
    By TheWhopper858 in forum Collections and Generics
    Replies: 1
    Last Post: November 6th, 2011, 08:50 PM
  2. Need help with C++ min and max heaps.
    By javapenguin in forum Other Programming Languages
    Replies: 6
    Last Post: October 19th, 2011, 11:08 AM
  3. Replies: 5
    Last Post: May 24th, 2011, 10:39 AM
  4. Help with Finding Max and Min Values of ArrayList
    By CheekySpoon in forum Collections and Generics
    Replies: 3
    Last Post: March 2nd, 2011, 08:57 PM
  5. Printing the Max and Min in an Array
    By bonbon242 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 29th, 2010, 08:28 AM