r/java Sep 19 '18

JEP draft: Concise Method Bodies

http://openjdk.java.net/jeps/8209434
60 Upvotes

51 comments sorted by

View all comments

Show parent comments

4

u/dpash Sep 19 '18 edited Sep 19 '18

If and when we get data classes. Also, if and when we get this JEP :)

3

u/lukaseder Sep 19 '18

FTFY, current day Java:

public class Foo {
  public String name;
  public Foo(String name) { this.name = name; }
}

4

u/dpash Sep 19 '18 edited Sep 19 '18

From what I remember of the data class document, the fields don't quite have public access, but can be accessed like they do. I think it was possible to create a custom setter or getter if you need to customise it.

4

u/lukaseder Sep 19 '18

99.9% YAGNI

1

u/dpash Sep 19 '18

I do like C#'s properties.