Compound data type: Difference between revisions
Content added Content deleted
(Jakt) |
|||
Line 1,143: | Line 1,143: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
Starting with Java 14 you can use a record |
|||
<syntaxhighlight lang="java"> |
|||
record Point(int x, int y) { } |
|||
</syntaxhighlight> |
|||
Usage |
|||
<syntaxhighlight lang="java"> |
|||
Point point = new Point(1, 2); |
|||
int x = point.x; |
|||
int y = point.y; |
|||
</syntaxhighlight> |
|||
<br /> |
|||
Alternately |
|||
We use a class: |
We use a class: |
||
<syntaxhighlight lang="java">public class Point |
<syntaxhighlight lang="java">public class Point |