我想要的是打印出每种方法,而不是将它们的值加在一起。我认为这就是为什么在尝试将布尔值放入第一个System.out语句时出错的原因。我必须给每个人自己的System.out.println语句吗?
public class Main {
public static void main(String[] args)
{
Block dirt = new Block(1, 100, 1, false, false, 0, 1, 100, 1)
{
};
System.out.println(dirt.getSpawnLevel() + dirt.getSize() + dirt.getHardness() + dirt.getOpacity() + dirt.getRarity() + dirt.getBounceHeight() + dirt.getStackSize());
System.out.println(dirt.getFlammable());
System.out.println(dirt.getBlockBounce());
}
}
最佳答案
Block dirt = new Block(1, 100, 1, false, false, 0, 1, 100, 1)
{
};
通过以下方式更改以前的代码:
Block dirt = new Block(1, 100, 1, false, false, 0, 1, 100, 1);
还要像这样打印输出:
System.out.println(dirt.getSpawnLevel()+"," + dirt.getSize()+"," + dirt.getHardness()+"," + dirt.getOpacity()+"," + dirt.getRarity()+"," + dirt.getBounceHeight()+"," + dirt.getStackSize());