Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes cannot resolve symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "cannot resolve symbol" Watch "cannot resolve symbol" New topic

cannot resolve symbol

vishal mishra
Ranch Hand

Joined: Jul 12, 2010
Posts: 103
Java Compiler is giving Error "cannot resolve symbol while i am trying to compile the file

Here is my program

Please !!! Help Me!!!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

You can UseCodeTags to post your code (this time I have done it for you )

And are you aware that Java API has a Stack class? So your class Stack would conflict with java.util.Stack.

And You need to post the exact compiler error you see, that will help us to guide you to the solution

Mohamed Sanaulla | My Blog
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15080

What is the exact error message and on which line of your source code does it happen? All the details in error messages are important, and give you exact information where and what is wrong. Read the error message carefully.

"Cannot resolve symbol" means that you're using a name (of a variable, method, class etc.) that the compiler doesn't recognize.

Looking at your code, I see at first sight that there are errors on lines 9, 10 and 11 of StDemo. If you want to call the pop() method on your class Stack, you'll need to write that as my.pop(), not my.pop.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ben Ooms
Ranch Hand

Joined: May 16, 2011
Posts: 44

The troubles start at line 2,
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
You ought to put the [] before the name of the reference. The compiler might not complain, but it is better style.
Then you see you are creating an int[] but assigning it to a st[]. Surely that ought to be a new int[123]?
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

i will just add this. usually when you get that particular compiler error, it means you forgot to import something

Visit my download page
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
Not in this case, I wouldn’t think.
I agree. Here's the link:
subject: cannot resolve symbol
It's not a secret anymore!