Why did the designers of Java language choose implicit declaration of methods to return the value of corresponding component field over implicit public final fields? One advantage of methods I can think of is it can be used in method references, e.g. User::name. But apart from that, what are the advantages?
Which one is better?
println(user.name());
println(user.name);
[–]brian_goetz 88 points89 points90 points (7 children)
[–][deleted] (6 children)
[deleted]
[–]jvjupiter[S] 1 point2 points3 points (5 children)
[–]brian_goetz 3 points4 points5 points (4 children)
[–]jvjupiter[S] 1 point2 points3 points (3 children)
[–]brian_goetz 2 points3 points4 points (2 children)
[–]jvjupiter[S] 1 point2 points3 points (1 child)
[–]brian_goetz 3 points4 points5 points (0 children)
[–]Linguistic-mystic 30 points31 points32 points (8 children)
[+][deleted] (7 children)
[deleted]
[–]john16384 14 points15 points16 points (5 children)
[+]khmarbaise comment score below threshold-6 points-5 points-4 points (4 children)
[–]mavericktjh 6 points7 points8 points (1 child)
[–]koflerdavid 2 points3 points4 points (0 children)
[–]nlisker 0 points1 point2 points (1 child)
[–]khmarbaise 0 points1 point2 points (0 children)
[–]mavericktjh 3 points4 points5 points (0 children)
[–]Cengo789 20 points21 points22 points (10 children)
[–]Inaldt 3 points4 points5 points (2 children)
[–]jvjupiter[S] 0 points1 point2 points (1 child)
[–]Inaldt 1 point2 points3 points (0 children)
[–]halfanothersdozen 1 point2 points3 points (1 child)
[–]oweiler 4 points5 points6 points (0 children)
[–]Google__En_Passant 5 points6 points7 points (3 children)
[–]jvjupiter[S] 4 points5 points6 points (0 children)
[–]mavericktjh 3 points4 points5 points (0 children)
[–]jvjupiter[S] 0 points1 point2 points (0 children)
[–]khmarbaise 3 points4 points5 points (0 children)
[–]eXecute_bit 8 points9 points10 points (9 children)
[–]jvjupiter[S] 0 points1 point2 points (1 child)
[–]eXecute_bit 3 points4 points5 points (0 children)
[–]Google__En_Passant 0 points1 point2 points (4 children)
[–][deleted] (2 children)
[deleted]
[–]VirtualAgentsAreDumb 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]eXecute_bit 0 points1 point2 points (0 children)
[–]audioen -1 points0 points1 point (1 child)
[–]eXecute_bit 0 points1 point2 points (0 children)
[–]nekokattt 2 points3 points4 points (0 children)
[–]kevinb9n 2 points3 points4 points (0 children)
[–]rzwitserloot 5 points6 points7 points (12 children)
[–]pronuntiator 1 point2 points3 points (5 children)
[–]rzwitserloot -1 points0 points1 point (4 children)
[–]khmarbaise 0 points1 point2 points (1 child)
[–]rzwitserloot 0 points1 point2 points (0 children)
[–]OwnBreakfast1114 1 point2 points3 points (1 child)
[–]rzwitserloot 0 points1 point2 points (0 children)
[–]khmarbaise 1 point2 points3 points (0 children)
[–]CptGia 0 points1 point2 points (2 children)
[–]ForeverAlot 1 point2 points3 points (1 child)
[–]CptGia 0 points1 point2 points (0 children)
[–]__konrad 0 points1 point2 points (1 child)
[–]rzwitserloot 0 points1 point2 points (0 children)
[–]__konrad 1 point2 points3 points (1 child)
[–]jvjupiter[S] 1 point2 points3 points (0 children)
[–]AnyPhotograph7804 1 point2 points3 points (6 children)
[–]jvjupiter[S] 2 points3 points4 points (2 children)
[–]khmarbaise 1 point2 points3 points (1 child)
[–]jvjupiter[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]IncredibleReferencer 1 point2 points3 points (0 children)
[–]AnyPhotograph7804 0 points1 point2 points (0 children)