Incompatible types when returning value

后端 未结 3 1989
野的像风
野的像风 2021-01-26 11:15

I want to display an image with drawn lines on a map, and separate images made for every single section in the image (several connected lines). I have written this code:

3条回答
  •  耶瑟儿~
    2021-01-26 11:52

    some people may find confusing when they don't know that

    BufferedImage lineImage1[] = null;
    

    is the same as

    BufferedImage[] lineImage1 = null;
    

    and you cannot have two returns, it's illegal in Java.

    So if you want to return more than one object, you can do something like

    public Object[] getLineImage() {
    (...)
        Object[] o = new Object[2];
        o[0]=lineImage;
        o[1]=lineImage1;
        return o;
    }
    

提交回复
热议问题