我想找出通过方法传递的数字是否是随机生成的对象(从树形图创建)的一部分。我一直在网上寻找一个可以帮助我找到它的类的属性,但结果很短,我尝试过 HashCodes、Equals() 等等......目前我已经设置好了像这样,我想我要问的是,我使用的是对还是错?
Here's the code:
public class a {
private final TreeMap<Integer,TreeMap<Integer,Double>> rectangle;
private final int height;
private final int width;
public a(int h, int w) {
this.rectangle = new TreeMap<>();
this.height = h;
this.width = w;
}
public double get(int i, int j) {
if ( i > j ) {
largest = i; // defined earlier
}
for(int a = 0; a < largest; a++) {
if (this.height.equals(a) == i && this.width.equals(a) == j){
int[] position = new int[1];
position[0] = i;
position[1] = j;``
}
else {
return 0.0;
}
}
}