This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I valid my invalid cast?

 
Elahe Shafie
Ranch Hand
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I have an error which says I used invalid cast from int to boolean! but the other side strWork is string and I do not understand what it says?
Could you please help me on this?
Many thanks,
Elahe
Error:
=========
Invalid cast from int to boolean.
if( strWork.compareTo( "0" ) ) {
^
Invalid cast from int to boolean.
else if( strWork.compareTo( "1" ) ) {
^
2 errors

If you like to see whole file:


[/code]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compareTo() method of the String class returns an int. An "if" test requires a boolean. Why not use the equals() method instead. It returns a boolean and should solve your problem.
 
Elahe Shafie
Ranch Hand
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many thanks Marilyn and now it works
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic