oop « collection « Java Collection Q&A

Java Collection Q&A
3.Array Byte
4.Array Char
5.Array Convert
6.Array Dimension
7.Array Integer
8.Array Object
9.Array String
14.Garbage Collection
Java Collection Q&A » collection » oop 

1. Good uses for Apache CollectionUtils    stackoverflow.com

I found the CollectionUtils class a year or so ago and a few of the methods like, collect, and transform seem really cool, however, I have yet to find ...

2. To use nested genericized collections or custom intermediate classes?    stackoverflow.com

Before the introduction to generics to the Java language I would have written classes encapsulating collections-of-collections-of-collections. For example:

class Account {
   private Map tradesByRegion; //KEY=Region, VALUE=TradeCollection

class TradeCollection {

3. OOP Terminology: "Container" & "Collection"    stackoverflow.com

Is the C++ term "Container" simply synonymous with the Java term "Collection" ?

4. Access to private Collection fields in Java    stackoverflow.com

One of my classes has a field which contains a Set. This field is only ever filled in the constructor, and then read by other classes. Originally I had something like ...

5. Is it acceptable to return unmodifiableList or should I return array?    stackoverflow.com

I have method List<Foo> getFoos () which gets the data from remote server and returns it. Of course, user shouldn't change number of items of the list because he'll get data not ...

6. Using Java generics in interfaces that return collections. Best practice? Pitfalls?    stackoverflow.com

I ran into some code today that I found questionable. Here's a simplified example (not realistic).

public interface IListable {
    //returns first n items from list

7. Can java method arguments be collections of a declared size?    stackoverflow.com

Is there a way in java to declare a method argument, that is some sort of collection, but with a finite size? For example, something like:

public Car(String colour, Wheel[4])
suggesting that a ...

8. Why does some libs define their own collections?    stackoverflow.com

For example, in Jsoup, they defined a class Elements to collect Element(s). It's common to define a class A and As which contains a lot of A(s). But why? Why ...

9. How to use Collection API?    stackoverflow.com

I have a packet having fields : Root Level : CHOICE Level 1 : SET Level 2 : SEQUENCE , CHOICE Note : CHOICE :- You can have one available fields.

SET :- Fields can ...

10. Can I avoid adapter classes when composing heterogeneous collections?    stackoverflow.com

I need a single collection of "processor" classes (I happen to be using Java) that can operate on a concrete shape, say a circle. Some of the classes can operate ...

11. Producing an abstract collection from an abstract collection    stackoverflow.com

This issue has been bugging me for a while. Abstractly speaking, regardless of language, there are often situations when you want to have a method like this:

Collection method(Collection c) {

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.