Results 1 to 2 of 2
Thread: general advice needed
- 03-18-2010, 03:42 PM #1
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
- 03-18-2010, 04:25 PM #2
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
- By sAntA199 in forum New To JavaReplies: 23Last Post: 12-04-2009, 11:10 AM
- By dineshjf in forum Advanced JavaReplies: 18Last Post: 01-09-2009, 04:17 AM
- By sanjeevtarar in forum Advanced JavaReplies: 15Last Post: 05-06-2008, 07:16 AM
- By Hatrabbit in forum New To JavaReplies: 2Last Post: 11-30-2007, 05:38 PM
- By JavaForums in forum NetBeansReplies: 0Last Post: 08-02-2007, 01:11 PM