Cannot find Symbol error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Cannot find Symbol error

I have two stocks, etStock ( which has a getExtra() method ) and a mfStock ( which does NOT have a getExtra() method ). The getExtra() method just returns an extra name for the stock ( etStock can have this extra name, but mfStock cannot ) Question: The error is explained in the code. Cannot find Symbol, and it suggests me to put getExtra() in the Stock class, but both etStock AND mfStock extends Stock and ONLY etStock can have the getExtra method for adding an extra name to the stock https://code.sololearn.com/cLg1JBXL38cJ/?ref=app

3rd Apr 2020, 3:06 PM
Fare Jare
Fare Jare - avatar
2 Answers
+ 1
Fare Jare Without creating the object of class you can't call method directly. Do like this etSrock e = new etStock(); e.getExtra();
3rd Apr 2020, 6:29 PM
A͢J
A͢J - avatar
0
Basically I'm looking through an array of stocks ( stored in arrObj[temp] ) and I have to access the getExtended(). I have to do this and see if it equals the users input for extended. I can't write it like this: arrObj[temp].e.getExtended().equals(userExtendedInput)) . How would I form this?
5th Apr 2020, 8:37 PM
Fare Jare
Fare Jare - avatar