Jump to content

Compound data type: Difference between revisions

(Jakt)
Line 1,143:
 
=={{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:
<syntaxhighlight lang="java">public class Point
118

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.