Skip to content
Reference > Classes

Collection

Definition

Collection var = .... ;

Extends

Extended By

Method Summary

Owner Name Return Type Description
Collection addAll(valuesToAdd) Object Adds all elements contained in the iterable to this collection
Collection clear() Boolean Removes all elements in this collection. Returns "true" if this operation removed at least 1 element, returns "false" if it was empty.
Object getClassName() String Returns the string name of this object's class type.
Iterable iterator() Iterator Returns an iterator over this container's objects. Methods are defined in the Iterator class.
Collection size() Integer Returns the size of this collection
Collection sort() List Returns a sorted list of the specified collection. Sorting is done according to the elements' type's natural ordering. This sort is guaranteed to be stable, equal elements will not be reordered as a result of the sort.
Object toJson() String Returns a string of a json representation of this object.

Method Definitions


addAll(valuesToAdd)

Object Collection::addAll(Iterable valuesToAdd)

Description

Adds all elements contained in the iterable to this collection

Parameter Definition

Name Type Description
valuesToAdd Iterable  The values to add to this collection

clear()

Boolean Collection::clear()

Description

Removes all elements in this collection. Returns "true" if this operation removed at least 1 element, returns "false" if it was empty.


getClassName()

String Object::getClassName()

Description

Returns the string name of this object's class type.

Example 7

1
2
3
4
Collection l = new List("a", "b", "c");
l.getClassName();

// l.getClassName() = List

Example 8

1
2
3
4
Collection s = new Set("a", "b", "c");
s.getClassName();

// s.getClassName() = Set

iterator()

Iterator Iterable::iterator()

Description

Returns an iterator over this container's objects. Methods are defined in the Iterator class.


size()

Integer Collection::size()

Description

Returns the size of this collection


sort()

List Collection::sort()

Description

Returns a sorted list of the specified collection. Sorting is done according to the elements' type's natural ordering. This sort is guaranteed to be stable, equal elements will not be reordered as a result of the sort.


toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.

Example 7

1
2
3
4
Collection l = new List("a", "b", "c");
l.toJson();

// l.toJson() = ["a","b","c"]

Example 8

1
2
3
4
Collection s = new Set("a", "b", "c");
s.toJson();

// s.toJson() = ["a","b","c"]