Results 1 to 2 of 2
  1. #1
    mac's Avatar
    mac
    mac is offline Member
    Join Date
    Dec 2009
    Location
    St. Petersburg, Russia
    Posts
    81
    Rep Power
    0

    Default general advice needed

    Problem: Get a single method to "return" 2 things

    Say i have a a method does 2 things - reads a file and (while we're at it) figures out if file containt duplicate keys.

    It then returns a properties that represents the file that just was read. Since a method can not return 2 things (right?).

    I was thinking of taking that Properties object and storing it as part of an ArrayList . Then i would take all duplicates i already found, storethem in another Properties object and add them to the same Array List.

    After all this, i would return a single Array List containing actual non duplicates file content and duplicates.

    I hope that this makes sence.

    Can you suggest a better approach or what i described is Ok?

    Ultimately - I would like to avoid redundancy and use a single method to accomplish 2 tasks

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    I'd create a new class called FileCheckResult that encapsulates all the things determined by your method and return an object of that class.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. making a general tree
    By sAntA199 in forum New To Java
    Replies: 23
    Last Post: 12-04-2009, 10:10 AM
  2. Advice needed
    By dineshjf in forum Advanced Java
    Replies: 18
    Last Post: 01-09-2009, 03:17 AM
  3. General Discussion on Abstract
    By sanjeevtarar in forum Advanced Java
    Replies: 15
    Last Post: 05-06-2008, 06:16 AM
  4. Prerequisite advice needed
    By Hatrabbit in forum New To Java
    Replies: 2
    Last Post: 11-30-2007, 04:38 PM
  5. How to set General options in NetBeans IDE
    By JavaForums in forum NetBeans
    Replies: 0
    Last Post: 08-02-2007, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •