Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7970393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:23:33+00:00 2026-06-04T07:23:33+00:00

If have the following class … /** * Two dimensional cartesian point. */ public

  • 0

If have the following class …

/**
 * Two dimensional cartesian point.
 */
public class Point {
  public final double x;
  private final double y;

  public double y(){
  return this.y;
  }

}

I can retrieve values as follows Point.x or Point.y()
I thought it was good practice in OO languages to encapsulate data by not making it directly accessible and instead using accessors, but it would seem that using directly field access is more normal and readable.

Why doesn’t Java allow me to dispense which the ()’s for function calls that take no parameters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:23:34+00:00Added an answer on June 4, 2026 at 7:23 am

    When you think about it, code would become completely unreadable. When you encountered something like foo.bar, yhou wouldn’t know whether it was accessing a field, or calling a method.

    It could only work if you introduced a third kind of construct besides fields and methods: properties. If Java supported properties, accessing them without () would not harm readability. There’s no technical reason for why there are no property-like constructs in Java, it was just a design decision.

    But allowing the omission of parentheses in any method call without a parameter is a bad idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following class. In this, Iris is another class with some attributes. public
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
I have following class structure public class Limit { public double MinSelectedValue; public double
let say i have following class: class Shape { public int widht; public List<Point>
this is my first question I Have following class class ProDetection { public function
I have following class: public class PairOfDice { private Dice d1,d2; public int Value
I have the following class definition and the main(). Can someone please point me
I have following class ( entity ) @Entity public class Magazine { private int
I Have following problem: class Request<T> { private T sw; public Request() { //How
I have following class public abstract class Rule { protected Rule() { Nodes =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.