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 7187735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:54:46+00:00 2026-05-28T18:54:46+00:00

In Java, I can access a public member of a class using . as

  • 0

In Java, I can access a public member of a class using . as can be seen in the second line of the main method in the following example (for the sake of this example, ignore my poor use of encapsulation).

public class Test {
    public static void main(String[] args) {
        Position p = new Position(0,0);
        int a = p.x; // example of member access
    }
}

class Position {
    public int x;
    public int y;

    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Is the . considered an operator in the Java programming language, just as *, ~, and != are considered operators?


Edit – Extending the above example:

As has been pointed out, it seems that the Java language specification considers . to be a separator and not an operator. Yet, I would like to point out that . exhibits some behavior that does seem rather operator-ish. Consider the above example extended to the following:

public class Test {
    public static void main(String[] args) {
        Position p = new Position(0,0);
        int a = p . x; // a -> 0
        int x = 1;
        int b = p . x + x; // b -> 1
    }
}

class Position {
    public int x;
    public int y;

    public Position(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

It is clear that some precedence is being enforced such that the member access is evaluated before the addition. This seems intuitive because if the addition were to be evaluated first, then we would have p.2 which is nonsense. Nevertheless, it is clear that . is exhibiting behavior that the other separators don’t.

  • 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-05-28T18:54:47+00:00Added an answer on May 28, 2026 at 6:54 pm

    It’s considered a separator, not an operator. See the Java Language Specification sections 3.11 and 3.12 for a list of all separators and operators.

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

Sidebar

Related Questions

How can I access a public static member of a Java class from ColdFusion?
How can hibernate can access a private field/method of a java class , for
I can not access public method of my class MyPanel which extends JPanel .
How can I access a simple java object as a bean? For example: class
Java Q: I can't access a public variable in my parent's class' inner class
In Java you can access variables in a class by using the keyword this
A protected class member in Java by convention, can be accessed only from within
By convention, a static method specifically in Java can have access only to static
In Java, the inner class can access private members of enclosing class. But can
In Java in the equals(Object o) method I can access the private variables of

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.