开发者

what is it wrong with int[][]

Hi I have written a code that i will put just a part of that which has a problem. I have an arrayList<Point> which its size is 4. I have passed the 3 elements of this list to a method but with System.out.println I get 3 y instead of 1 y !! what is wrong .please help me.thanks

CODE:

    public int determinal(Object get, Object get0, Object get1) {
    Point point = (Point) get;
    Point point1 = (Point) get0;
    Point point2 = (Point) get1;
    int[][] data = new int[3][2];
开发者_运维百科    data[0][0] = point.getX();
    data[0][1] = point.getY();
    data[1][0] = point1.getX();
    data[1][1] = point1.getY();
    data[2][0] = point2.getX();
    data[2][1] = point2.getY();
    System.out.println(data[1][1]);
    return ((data[0][0] - data[2][0]) * (data[2][1] - data[2][1]) * (data[1][0] - 
data[2][1]) * (data[0][1] - data[2][1]));
    }

OUTPUT:

X :225  Y: 86
X :92  Y: 164
X :238  Y: 154
86
164
154

I prefer to print just 164 but it will print all y. Also I have another System.out.println that prints the X and Y of all my three points(this method doesn't mentioned above)


it's not really clear what you think the problem is but i think you are just confused because your variables are named inconsistently.

for example, if i remove the code irrelevant to the System.out.println call:

public int determinal(Object get, Object get0, Object get1) {
    Point point1 = (Point) get0;
    int[][] data = new int[3][2];
    data[1][1] = point1.getY();
    System.out.println(data[1][1]);
    }

and then further reduce it:

public int determinal(Object get, Object get0, Object get1) {
    System.out.println(((Point) get0).getY());
    }

can you see what is happening now?


I think something wrong with your calling method, can you post the sample for calling method?

Or make sure that you would have some looping control inside your calling method, that would be the reason for this cause.

-Saligh

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜