无法将createBufferStrategy设置为变量?

时间:2018-07-14 13:07:34

标签: java canvas

标题大致总结了一下。为什么我不能这样做?

private void render() {
    bs = window.getCanvas().getBufferStrategy();

    if (bs == null) {
        bs = window.getCanvas().createBufferStrategy(3); // this is the line with the error: cannot convert from void to BufferStrategy.
    }
}

但是我可以使用没有变量的createBufferStrategy(3)。为什么会这样?

1 个答案:

答案 0 :(得分:1)

createBufferStrategy返回void(或者,什么也不返回)。它不是它创建的返回BufferStrategy