This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot resolve symbol  RSS feed

 
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!!!
 
Bartender
Posts: 3185
34
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
 
Java Cowboy
Sheriff
Posts: 16081
88
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.
 
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,
 
Sheriff
Posts: 57927
178
  • 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]?
 
Ranch Hand
Posts: 4702
9
Java Scala
  • 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: 57927
178
  • 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
Boost this thread!