Does some interface like below already exist in Java?
interface Size {
int getWidth();
int getHeight();
}
Edit: It must be an interface.
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.
I’d recommend making your own rather than using
java.awt.Dimension, particularly if what you want is an interface and not a class. If you do want a class likeDimension, I still wouldn’t use it, but instead make another class as an immutable value type…Dimension‘s mutability is a major weakness. Every method that returns aDimensionis forced to return a copy of it, and every method that accepts aDimensionis forced to make a copy of it too. Had it been immutable, copying wouldn’t have been required in either case.