Point operator (programming languages)
The dot operator is an access operator that is part of many programming languages such as Pascal , C or Java . It is used to access elements of classes or data structures . Such accesses take place through calls of the form "Class.Method" or "Class.Attribute", which, for example, enable access to methods or attributes of a class.
The dot operator is very similar to the array access operator. With the dot operator, an identifier is used as a property, while the array access operator evaluates the content of a name and then accesses the value of this named property.
example
The following example for the use of the point operator is written in the Java programming language:
public class Auto {
public int kilometerstand;
public void losfahren() {
System.out.println("Das Auto fährt jetzt.");
}
}
public static void main(String[] args) {
Auto vw_kaefer = new Auto();
vw_kaefer.kilometerstand = 200.345;
System.out.println("Der Kilometerstand beträgt " + vw_kaefer.kilometerstand + " km.");
vw_kaefer.losfahren();
}
In the upper part, a class is defined with the attribute kilometerstand
and the method losfahren
. In the main class (below) an instance of Auto
with the name is first vw_kaefer
created. The second statement assigns a value to the attribute kilometerstand
of vw_kaefer
. This is queried and output in the next line. Finally, the “start driving” method is vw_kaefer
called.
Different meanings
The operator has does not exist in any programming language in which it, the same semantics (meaning), for example, the dot operator in has PHP a different semantics, here it is used to string ( character strings ) (to adhere to each other) to concatenate. In PHP, the code would have
$a = "Hallo" . " " . "Welt.";
the effect of getting $a
the value "Hallo Welt."
assigned. Instead of the point operator from the “C C ++ Java” world, the operator " ->
" exists in PHP .
Based on the mathematical notation, the operator . from Haskell's standard library the meaning of the functional composition .