add « Set « Java Collection Q&A

Home
Java Collection Q&A
1.algorithm
2.array
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
10.ArrayList
11.collection
12.comparator
13.Development
14.Garbage Collection
15.Generic
16.hash
17.HashMap
18.HashTable
19.iterator
20.LinkedList
21.List
22.Map
23.queue
24.Set
25.Sort
26.tree
Java Collection Q&A » Set » add 

1. adding another set Strings to TreeSet - java    stackoverflow.com

I have a public method (called getMusic) in a class called Favorites. getMusic has set. There are 3 sets and in each set has five words, Set getMusic(). In another class ...

2. Adding elements in a set    stackoverflow.com

I have to create a course with some undergraduate and postgraduate students, then extract from the course all postgraduate students with “Ismael Bento” as their supervisor using the method getPostgraduates() and ...

3. Add multiple fields to Java 5 HashSet at once?    stackoverflow.com

Is there a better way to do this so I don't have to have 50 ".add()"s in there? Like a comma separated list or something (like JavaScript arrays).

private static final Set<String> ...

4. Java's TreeSet.add() does not follow the PECS principle issue (Generics)    stackoverflow.com

I have the following piece of code:

public interface Segment<T> extends Period { ... };

public class SegmentImpl_v1<T> implements Segment<T> { ... };


public interface TimeLine<T, S extends Segment<T>> { ... };

public class TimeLineImpl<T, ...

5. Generics in HashSet add operation.    coderanch.com

Your declaration is for a variable "s", while the error message is about code related to a variable called "set". Apparently both of these are Sets, and you seem to think that they have something to do with each other. But I suspect that the compiler considers "s" and "set" to be two different things. Perhaps you could show us the ...

6. Hashset and Custom Objects problem! Wont add! :(    java-forums.org

thanks static was the reason why states were called the same. It adds fine now thanks :) However... ive added them to a LinkedHashSet so that the order in which they are inserted are preserved. How would I retrieve say state 4 as an object of type State from the LinkedHashSet and apply a certain method to it from the State ...

7. Adding to a HashSet    java-forums.org

Ok, I am using bluej and I am having trouble using a loop to add to a HashSet, as it just returns the size as null, saying there is nothing in it and I don't understand why. public Pack() { HashSet collection = new HashSet(); for (int count = 0; count < 21) { collection.add(new Object()); count++; } }

8. Adding items to TreeSet    forums.oracle.com

From the plethora of information I'll say that you are not holding your tongue correctly. What does "all the others are rejected" mean? Is there some sort of error appearing? Is your application crashing? Does nothing crash/no errors and afterwards your set only contain one value? How did you determine that there is only one value in your set? The more ...

9. how to add contents of hashset to file?    forums.oracle.com

10. Adding parentheses to each item in HashSet    forums.oracle.com

12. Class Cast problem when attempting to add Object in TreeSet, Please Help...    forums.oracle.com

Error: java.lang.ClassCastException: com.WeatherReport at java.util.TreeMap.compare(TreeMap.java:1093) It appears that com.WeatherReport objects are not comparable, and result in this ClassCastException when the 2nd object added to the TreeMap is compared to the 1st object, so that they can be ordered. Do you need to implement a comparator/comparable condition? My Java version appears to be different from yours, as line number 1093 is meaningless ...

13. About the implementation of HashSet.add( ) method    forums.oracle.com

You'd have to ask the original author of the class why he chose to do that. Maybe he wanted to decouple that value from the specific backing Map implementation. Currently the backing Map is HashMap, which allows null values, but some Maps don't. If they decide to change the backing map to one that doesn't allow null, they don't have to ...

14. Creating your own add() method for hashset    forums.oracle.com

First cross check the code written in addPosition method. Second the constructor of Portfolio class: Portfolio portfolio = new Portfolio(null); when you do this, it sets the null to reference variable of position class i.e _position = null, and in addPosition method you are adding this variable to Hashset. After correcting the above points if it still won't work, then i'll ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.