Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot resolve symbol

 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Compiler is giving Error "cannot resolve symbol while i am trying to compile the file StDemo.java

Here is my program






Please !!! Help Me!!!
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Ooms
Ranch Hand
Posts: 47
Debian Eclipse IDE Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The troubles start at line 2,
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i will just add this. usually when you get that particular compiler error, it means you forgot to import something
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not in this case, I wouldn’t think.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic