
Data Structure

This illustrates a data structure, a means of storing data within a program.

You may see other such structures in the Data Structures category.


Task

Create a compound data type:

  Point(x,y) 



A compound data type is one that holds multiple independent values.



Related task

   Enumeration


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


/* NetRexx */
options replace format comments java crossref symbols nobinary
 
class RCompoundDataType
  method main(args = String[]) public static
    pp = Point(2, 4)
    say pp
    return
 
class RCompoundDataType.Point -- inner class "Point"
  properties indirect -- have NetRexx create getters & setters
    x = Integer
    y = Integer
 
  method Point(x_ = 0, y_ = 0) public -- providing default values for x_ & y_ lets NetRexx generate intermediate constructors Point() & Point(x_)
    this.x = Integer(x_)
    this.y = Integer(y_)
    return
 
  method toString() public returns String
    res = 'X='getX()',Y='getY()
    return res
 