Special variables: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Special variables in FreeBASIC)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 1,018:
 
=={{header|Java}}==
Java is heavily object-oriented, and is mostly statically-typed. There aren't many special variables, or aggregates, similar to dynamically-typed languages.<br />
 
There is ''null'', which is used to represent an object which has no reference assigned.
<syntaxhighlight lang="java">
Object object = null
</syntaxhighlight>
 
There is ''true'' and ''false'' which are used to denote a ''Boolean'' value.
<syntaxhighlight lang="java">
boolean value = true
</syntaxhighlight>
 
There is the ''this'' and ''super'' variables, used to reference the current class and parent class, respectively.
<syntaxhighlight lang="java">
this.object
</syntaxhighlight>
<syntaxhighlight lang="java">
super(value)
</syntaxhighlight>
 
To avoid confusion to anyone unfamiliar with Java, there is the ability to import static, final, variables from other classes.<br />
While these are not 'special variables' they may appear that way to a new user.
<syntaxhighlight lang="java">
import static java.lang.Math.*;
</syntaxhighlight>
<syntaxhighlight lang="java">
double area = PI * (2 * 2);
</syntaxhighlight>
 
There is the first parameter of the ''main'' method, which is of type ''String[]''.<br />
It is non-null and includes any arguments depicted during execution.
<syntaxhighlight lang="java">
public static void main(String[] args)
</syntaxhighlight>
<br />
Additionally ...<br />
Java has only a few special variables. There is a <code>String</code>-Array for passing command-line-arguments to the program, and there is a <code>Class</code>-Object that can be accessed in a variable-like manner. It is used for reflection, (like examining and modifing class members, their type and modifiers during runtime).
There is the <code>System</code>-"Object" that contains various (mostly static) data about the enviroment the Java VM runs on, and it's cousin <code>Runtime</code> that provides data that is more prone to change during runtime, like available CPU cores and RAM.
Line 2,197 ⟶ 2,232:
 
=={{header|Wren}}==
Wren has two special variables ''this'' and ''super''. These can only beWhen used in a constructor or instance method of a class. ''this'' refers to the current instance and ''super'' refers to a super-class whose constructor or (typically overridden) method you wish to invoke. Here's an example.
<syntaxhighlight lang="ecmascriptwren">class Parent {
construct new(name) {
_name = name
Line 2,226 ⟶ 2,261:
My name is John and my parent's name is Fred.
</pre>
 
=={{header|Z80 Assembly}}==
It's somewhat debatable whether processor registers count as "variables," since they don't have a location in the address space but their contents can change. Excluding those for now, there are a few memory locations that have special meaning:
9,479

edits