New (Arraylist constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Create new Arraylist instance<section end=dpl_desc/></b></span> [[Category:Arraylist methods|New constructor...")
 
m (1 revision)
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Create new Arraylist instance<section end=dpl_desc/></b></span>
{{Template:Arraylist:New subtitle}}
[[Category:Arraylist methods|New constructor]]
<!--DPL?? Category:Arraylist methods|New constructor: Create new Arraylist instance-->
<p>
New is a member of the [[Arraylist class]].
</p>


This method returns a new instance of an Arraylist.
==Syntax==
===Syntax===
{{Template:Arraylist:New syntax}}
  %arrayl = New
===Syntax terms===
====Syntax Terms====
<table class="syntaxTable">
<dl>
<tr><th>%al</th>
<dt><i>%arrayl</i>
<td>An Arraylist object variable that is set to a new Arraylist object reference.</td></tr>
<dd>An Arraylist object that is set to a new Arraylist object reference.
<tr><th nowrap="true"><var>[%(Arraylist Of </var>itemType<var>):]</var></th>
<td>The optional class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See "Usage notes," below, for more information about invoking a collection <var>Constructor</var>.</td></tr>
</table>


</dl>
==Usage notes==
===Usage Notes===
<ul>
<ul>
<li>New is a constructor and as such can be called with no method
<li>As described in [[Object variables#Using New or other Constructors|"Using New or other Constructors"]], <var>New</var> can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is <var>Null</var>:
object, with an explicit class name, or with an object variable,
<p class="code">%al = new
even if that object is null:
 
<pre style="xmp">
%al = %(Arraylist of float):new
    %arrayl = new
 
    %arrayl = %(Arraylist):new
%al = %al:new
    %arrayl = %arrayl:new
</p>
</pre>
'''Note:'''
:note
As shown above, when explicitly indicating the
When using the second of these syntax options of New, which explicitly indicates the
class, both the collection and the item datatype must be
class, both the collection and item datatypes must be
specified just as they are on the collection variable's declaration:
specified just as they are on the collection variable's declaration:
<pre style="xmp">
<p class="code">%arrayl  is collection Arraylist of longstring
    %arrayl  is collection Arraylist of longstring
%arrayl  = %(Arraylist of longstring):new
    %arrayl  = %(Arraylist of longstring):new
</p>
</pre>
</ul>
</ul>
==See also==
{{Template:Arraylist:New footer}}

Latest revision as of 20:24, 30 November 2011

Create a new Arraylist object (Arraylist class)


Syntax

%al = [%(Arraylist Of itemType):]New

Syntax terms

%al An Arraylist object variable that is set to a new Arraylist object reference.
[%(Arraylist Of itemType):] The optional class name in parentheses denotes a Constructor. See "Usage notes," below, for more information about invoking a collection Constructor.

Usage notes

  • As described in "Using New or other Constructors", New can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is Null:

    %al = new %al = %(Arraylist of float):new %al = %al:new

    Note: As shown above, when explicitly indicating the class, both the collection and the item datatype must be specified just as they are on the collection variable's declaration:

    %arrayl is collection Arraylist of longstring %arrayl = %(Arraylist of longstring):new

See also