• Post Reply Bookmark Topic Watch Topic
  • New Topic

LIFO Stack/Reverse Polish Notation  RSS feed

 
Dinah Gans
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know why I'm getting this error on line 27? Why does Java think that (operatorstk.pop()) should be an int? hmmm

incompatible types
found : java.lang.String
required: int
switch (operatorstk.pop()) //operator = 1st on operator Stack
^
1 error



etc...
 
Bert Wilkinson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yo Dinah.

you can't execute a switch statement on a String.

Take a look at this link:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/switch.html
 
Dinah Gans
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh ok! Thanks a lot Bert!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!