If I have this line in the code java.util.Collection search = searchQuery1.getResultList(); Is this a collection of <list>? and can I find out if search should be named"Search" or does it have to be instantiated of something?

There is absolutely no way to tell the type of the collection from that line of code. The return type of that method will be documented by whatever API describes the class of "searchQuery1".

The question about "search" vs "Search" doesn't make any sense - it's your variable declaration, call it whatever you want.

Here is a link I was given that might help.

http://java.sun.com/j2se/1.5.0/docs/api/

I was given a much better example. the collection must contain an array of resultsets it calls getResultSet().


java.util
Class AbstractCollection<E>

java.lang.Object
extended by java.util.AbstractCollection<E>

All Implemented Interfaces:
Iterable<E>, Collection<E>

Direct Known Subclasses:
AbstractList, AbstractQueue, AbstractSet

public abstract class AbstractCollection<E>
extends Object
implements Collection<E>

This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.

To implement an unmodifiable collection, the programmer needs only to extend this class and provide implementations for the iterator and size methods. (The iterator returned by the iterator method must implement hasNext and next.)

To implement a modifiable collection, the programmer must additionally override this class's add method (which otherwise throws an UnsupportedOperationException), and the iterator returned by the iterator method must additionally implement its remove method.

The programmer should generally provide a void (no argument) and Collection constructor, as per the recommendation in the Collection interface specification.

The documentation for each non-abstract methods in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.

This class is a member of the Java Collections Framework.

Since:

Here is another helpful example given:
The collection contains the same type of objects as are contained in the returned list.

For example, if the returned list contains Integers, then the Collection will also contain Integers. In this case the declaration would look something like this...

import java.util.Collection;

Collection<Integer> search = searchQuery1.getResultList();

Thanks for posting generic information on a Collection for whoever might randomly need such, but it doesn't change the fact that the actually return type of that collection can only be ascertained by the api itself. Perhaps you need to reword your original question, because based upon this last post above it's not very clear what you are wanting to know.

Try to keep up. I gave a link to answer any of your questions;

You gave a link to the JDK 1.5 api doc index, copied a description of an AbstractCollection, and asked a nearly incomprehensible question. What am I trying to keep up with exactly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.