Query Types
This section shows by example, the query types supported by our
Java Examples
database (what to enter in the search field -- note that
queries are case sensitive).
- Class-name - Find all examples for class "Thread".
Returns a list of every method on Thread that we have examples of; in addition it will show an entry labeled
"new" if we have examples that instantiate the class
and an entry for any extends/implements examples.
Each entry in the list is a link, and clicking it will run a query for that Class.method, or instantiation, etc.:
- Invoke Class.method - Find example code that invokes the Class.method "URL.openConnection" (note: case sensitive):
- Invoke package.Class.method - Same as above, but specify full package name (do this if, for example, a class named 'URL' is
found in multiple packages -- a message in the query results will tell you when this occurs):
- Implements Classname - Find classes that implement interface "Runnable". The search results will show classes
which implement the interface. Note that for this type of query the search results cannot always pinpoint the
class
statement
where the implements
clause occurs; when we can't pinpoint it, we will point to the first executable code or constructor that follows
the implements
clause:
- Extends Classname - Find classes that extend (subclass) a class (note: direct inheritance -- not transitive).
Note that for this type of query the search results cannot always pinpoint the
class
statement
where the extends
clause occurs; when we can't pinpoint it, we will point to the first executable code or constructor that follows
the extends
clause. Example, find classes that extend class "DateFormat":
Complexity
Our database also contains a measure of the complexity of the method in which each example lives. You can use this to
further qualify your Class.method query by specifying an optional "complexity:
n
" clause with an
n
value of 1, 2 or 3,
where 1 is low complexity and 3 is high.
If you specify 2, for example, then only Java examples that occur in methods of medium complexity will be returned. For example, to find examples of Date.getTime
in medium complexity methods, enter the query:
Note that this "complexity:
n
" clause cannot be used in
Class-name
queries, and is not used for
implements
and
extends
queries, since these usually do not occur within methods. Also, if your query does not specify a complexity
clause then all complexities are returned.