Question: I'm creating a Java code and keep getting this error > TestClass.java:26: error: non-static method isEmpty(LetterInventory) cannot be referenced from a static context I have
I'm creating a Java code and keep getting this error >
TestClass.java:26: error: non-static method isEmpty(LetterInventory) cannot be referenced from a static context
I have code from 2 separate Java files that are conflicting.
For the first file, LetterInventory, it compiles without issue. I have:
public int size() { return size; } // end size // If Letter Inventory is empty, returns true. // If Letter Inventory is not empty, returns false. public boolean isEmpty(LetterInventory p) { if(size == 0) { return true; } return false;
The 2nd file, TestClass, is the one giving me the error:
String insert = scan.next(); LetterInventory v = new LetterInventory(insert); if(LetterInventory.isEmpty(v)) { There are a few more pieces of code surrounding it, but it's mostly println's, so I don't think it has anything to do with it.
Please help! If you could also give an example of what would work in the code, that would be amazin.g
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
