标题大致概括了这一点。为什么我不能这样做?
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)。这是为什么?
最佳答案
createBufferStrategy
返回void
(或者,嗯,不返回任何内容)。它不会返回 BufferStrategy
它创造。
关于java - createBufferStrategy 不能作为变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51338807/