Java的新功能,索引有什么问题?

时间:2019-09-12 15:20:19

标签: java

我是Java新手。 我在学校没学过C。 我真的很想学习Java。 所以我开始了一个小项目。 我陷入了这个nullPointerException。

public class Item{
public Item(){
        setItemType("Dirt");
        setAmount(64);
        isBlock = true;
    }
}

public class Inventory {
    Item items[] = new Item[36];
    int currentSlot = 0;
}

void Describe(){
        System.out.println(Name + " has " + Health + " health points.");
        System.out.println(Name + " has " + Exp + " exp. points.");
        System.out.println(Name + " has a " + inv.items[inv.currentSlot].getItemType() + " block in his hands.");
    }

您能帮助我了解我的代码有什么问题吗?

Github repo for the entire code of my project

0 个答案:

没有答案
相关问题