/** * Static factory methods that returns new QueryArray using * the passed fixed array "array" */1static from(array) { //Call traditional constructor return new this(array); } /** Traditional constructor -- set ivar elements to passed array */2constructor(array) { this.elements = array; } /** Returns nice display string */3toString() { return this.elements.toString(); }
class QueryArray { // ----------------------------------------------------- //Instance Variables (Ivars) //this.elements -- a fixed array holding the elements // ----------------------------------------------------- //Constructors /** Static factory methods that returns new QueryArray using the passed fixed array "array" */ static from(array) { //Call traditional constructor return new this(array); } /** Traditional constructor -- set ivar elements to passed array */ constructor(array) { this.elements = array; } // ----------------------------------------------------- //Core Instance Methods /** Returns nice display string */ toString() { return this.elements.toString(); } } _br_ _br_//Test It //fixed array and query array var farray, qarray; //Example data (list of cities) farray = City.newSampleSet1(); //Construct QueryArray qarray = QueryArray.from(farray ); //Print It println(qarray)