Both x and y and integers, while getX() and getY() returns a doubles.
Why aren’t there e.g. getXIntValue(), getXDoubleValue() and vice versa for y?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
As others have said, it’s because it’s ancient. But I like it because it saves typing and adds clarity; IMHO getters and setters can be a waste of time for simple classes if they’re public and all they’re going to do is to return the value and set it, which is all you want 99% of the time.
Design philosophy changed and now everything uses them. But things are coming full circle and in a modern languages like Groovy these would be “properties” with getters / setters inferred and syntax pretty similar to that for accessing public fields in Java.
E.g. http://groovy.codehaus.org/Groovy+Beans
Edit: and according to an (unofficial) Scala style guide,