Another syntax for Java records
Heinzl, Steffen
steffen.heinzl at fhws.de
Tue Nov 22 21:25:20 UTC 2022
Hi!
I wanted to suggest (if not yet done) to another syntax to Java records.
I don't quite understand the idea behind the syntax except that some other programming languages do it similar.
A Java class looks like this:
public class MyClass
{
String s;
void myMethod(String a, int b);
}
An interface looks like this:
public interface MyInterface
{
void myMethod(String c, String d);
}
Why all of a sudden is it a good idea to change that syntax to:
public record MyRecord(String r, int x)
{
}
instead of the following syntax (which is also possible in C# by the way)
public record MyRecord
{
String r;
int x;
}
I'm teaching Java and I find it strange from a lecturer's point of view to explain the rationale for introducing the syntax like that. I'd be glad if someone could enlighten me!
Thanks! Best,
Steffen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20221122/53fa382c/attachment.htm>
More information about the amber-dev
mailing list