I know this error very well however this is the once time I\'m stumped. I know that I can\'t call non-static variables from main method but this is confusing. Maybe you can help
You can't call a non static method from a static method. So either make addInv
static:
public class Item {
...
public static void main(String args[]) {
addInv(1);
}
public static void addInv(int e) {
...
}
public static String[] getItem(int e) {
...
}
}
But making all these methods static may not be an appropriate design, you might prefer using an Item
instance in your main
:
public class Item {
...
public static void main(String args[]) {
Item item = new Item();
item.addInv(1);
}
}
By the way, I don't mean to be rude but you should seriously work on your (awful) code formatting and conventions, both for readers and for you.