Java 如何使用已定义的对象作为输入变量?

Java 如何使用已定义的对象作为输入变量?,java,object,boolean,polymorphism,Java,Object,Boolean,Polymorphism,我以前定义过坐标类,因为它需要两个整数,现在我想在我的另一个类中使用它,比如 public boolean isLocationValid( Coordinates location ){ ...and here I want to define that location should be in the boundaries (for example 0<x<10 and 0<y<10) } public boolean isLocationV

我以前定义过坐标类,因为它需要两个整数,现在我想在我的另一个类中使用它,比如

public boolean isLocationValid( Coordinates location ){
       ...and here I want to define that location should be in the boundaries (for example 0<x<10 and 0<y<10)
    }
public boolean isLocationValid(坐标位置){

…在这里,我想定义位置应该在边界中(例如,0在
坐标
类上有getter,因此在
isLocationValid()
方法中,调用
location.getX()
location.getY()
。以扩展示例:

public boolean isLocationValid( Coordinates location ){
    // ...and here I want to define that location should be in the boundaries (for example 0<x<10 and 0<y<10)
    return isBetweenMinAndMax(location.getX() && isBetweenMinAndMax(location.getY()))
}

private final int MIN_EXCLUSIVE = 0;
private final int MAX_EXCLUSIVE = 10;
private isBetweenMinAndMax(int value) {
    return value > MIN_EXCLUSIVE && value < MAX_EXCLUSIVE;
}
public boolean isLocationValid(坐标位置){
//…这里我想定义位置应该在边界中(例如0
public boolean isLocationValid( Coordinates location ){
    // ...and here I want to define that location should be in the boundaries (for example 0<x<10 and 0<y<10)
    return isBetweenMinAndMax(location.getX() && isBetweenMinAndMax(location.getY()))
}

private final int MIN_EXCLUSIVE = 0;
private final int MAX_EXCLUSIVE = 10;
private isBetweenMinAndMax(int value) {
    return value > MIN_EXCLUSIVE && value < MAX_EXCLUSIVE;
}