This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Return Values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Return Values" Watch "Return Values" New topic

Return Values

henri henri
Ranch Hand

Joined: Oct 03, 2005
Posts: 115
I wrote a method that in theory returns a TreeSet full of film titles. It was tested within its own calss and works. When I use the same method in my other class as you see at the bottom where set is TreeSet, I did the tests to print out the contents, and there is nothing. The variable method parameter comes from the main class and is a selection in a JComboBox.

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703

Few questions, what's container defined as? Second, why do you use two iterators? If container is sorted this is ok, but if its not there's no guarentee the iterators are in the same ordering. For safety I tend to use one iterator and use the keySet() to retrieve the values such as:

As for your problem, there's not enough details to identify what is causing your results. Post more details.

My Blog: Down Home Country Coding with Scott Selikoff
I agree. Here's the link:
subject: Return Values
Similar Threads
What's wrong with this code? Why I am able to add duplicates with this code.
List in Descending order
Implementing Comparable/compareTo for a class with a collections member field
Formatting JTextArea