News for hackers. Stuff that matters.
Re:Java 9 features announced by spektom on Tuesday August 19, 2014 @04:15AM (#8196391)
If there's a getter and a setter for a class field, you can just make it public.
Re:Java 9 features announced by TheLoneWolfling on Tuesday August 19, 2014 @02:35PM (#8198994)
The problem is that in Java at least, you cannot.

At least if it will be ever used by code beyond your control.

Because then you'll never be able to add a getter or setter later without breaking people's code.

Java is frustrating in that regard. As it should be able to deal with automatically invoking getters and setters when needed (it already inlines getters and setters at runtime, this is "just" the reverse), but it's a language decision that it doesn't.

As an additional bonus, this would help reduce the (legendary) verbosity of Java. a.b += c.d is much easier to read than a.setB(a.getB() + c.getD()). And don't get me started on Java's generics or lack of operator overloading...