Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
The error message youre encountering indicates that youre trying to call a nonstatic method isEmpty ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started