Generic « 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 » Generic 

1. Java: Problems with TreeSet    stackoverflow.com

I have a class Odp. I want to use TreeSet to keep a sorted collection of Odp objects. However, I've been having problems.

public class OdpStorage {

    private TreeSet<Odp> ...

2. What is unchecked and unsafe operation here?    stackoverflow.com

I have the following code:

private static final Set<String> allowedParameters;
static {
    Set<String> tmpSet = new HashSet();
    tmpSet.add("aaa");
    allowedParameters = Collections.unmodifiableSet(tmpSet);
}
And it cause:
Note: mygame/Game.java ...

3. Generics and TreeSets    stackoverflow.com

Working with Generics is definitely my weak spot, and can use some help with this. The project is to develop a simple order/inventory system that places orders, keeps track of items and ...

4. wildcard generics in HashSet constructor    stackoverflow.com

The java HashSet implementation has a constructor:

public HashSet(Collection<? extends E> c) {
    map = new HashMap<E,Object>(Math.max((int) (c.size()/.75f) + 1, 16));
    addAll(c);
} 
Why it is Collection<? ...

5. Why is it possible to access a field without a getter?    stackoverflow.com

I have the following example:

package cage;

import java.util.HashSet;
import java.util.Set;

import animals.Animal;

public class Cage<T extends Animal> {  //A cage for some types of animals
    private Set<T> set = new HashSet<T>();

 ...

6. Generics and Collections: Duplicates in HashSet allowed?    coderanch.com

Hello, I am confused. According to the API a Set is "a collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2)...". In my code below however I am able to add duplicates though equals() keeps telling me that the Objects in questions (p1 and p2) are equal. Due to my ...

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.